class BigInt { private: static const int max_length = 300; int c; int number[max_length]; int to_int(char symbol) { return (symbol >= '0' && symbol <= '9') ? (int)symbol - '0' : -1; } public: BigInt(char* str) { c = strlen(str) - 1; int pos = 0; if (c > max_length) { cout << "Max length is " << max_length << "but your number has length" << c << endl; return; } for (int i = c; i <= 0; i--) { number[pos] = to_int(str[i]); pos++; } } void printNumber(void) { for (int i = c; i >= 0; i--) { cout << number[i]; } cout << "\n"; } }; There is a constructor that accepts a string-number, the digits of which is written into the array number. When outputting this array, I get for some reason random values.
int main(void) { char str[]="111111111"; BigInt test(str); test.printNumber(); return 0; }