Below are my codes:
char str [80];
int n;
n = MAX + ( rand () % 1000 + 1);
cout << "number: " << n << endl;
constructArray(str, n);
void constructArray (char str [], int n)
{
for (int i = 0; i < n; i++)
{
while (n > 0)
{
// get last pair of digits
str [i] = n%10;
n/= 10;
}
cout << str[i] << endl;
}
}
I can't figure out why my compiler doesnt output any values. It works if I didnt implement array.
Any help will be appreciated.