Hello everyone! I am a complete programming noob and am looking for a little help. I've written two functions one to read an array and one to print the array.
My read function works great and my print funtions works, but not like I want it to. What I need is to be able to print no more then 10 number per line.
Below is the code I've written to do such.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
void printF(int bry[])
{
int i = 0;
readF(ary, size); //Function I've written to read the array.
while (bry[i] != 0) //Using because I want to stop when it reaches a 0.
{
cout << bry[i] << " ";
if ((i % 10) == 9);
cout << endl;
i++;
}
return;
}
The function prints, but it only prints one number per line. What have I done wrong?
Are you aware that this code will result in an invalid memory access if there's no field with value 0?
Also size is undefined if it's not global (global is evil).
To solve your problem, remove the ; in the end of line 9 if ((i % 10) == 9)