I feel like I'm missing something obvious and I can't figure it out. Basically, it seems the information is correctly being stored in the first for loop. But when I go to print it out in the second for loop its only garbage values. What am I missing? I'm relatively new to this
bignum::bignum(const string &digits)
{
int length = digits.length();
ndigits = 0;
for (int i = 0; i < length; i++)
{
if(isdigit(digits[i]))
{
ndigits++;
digit = new int[ndigits];
int tmpInt = digits[i] - '0';
digit[i] = tmpInt;
}
if(isalpha(digits[i]))
{
break;
}
cout <<"step "<< i << " " << digit[i] << endl;
}
for (int i = 0; i < ndigits; i++)
{
cout << digit[i] << " ";
}
cout << endl;
cout << "digits" << ndigits << endl;
cout << endl;
}