displaying 5 items per line
Hello, I'm trying to display 5 items per line. My program outputs 6 items the first line and 5 items the second line. Any suggestions? Thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
void displayID(string array[], int& cnt)
{
int count = 0;
int i;
int num;
cout << "Student ID numbers on file are: " << endl;
for (count = 0; count < cnt; count++)
{
cout << array[count] << setw(11);
if ((count % cnt)==5)
cout << setw(0) << endl;
}
return;
}
|
Hello again, I got it to work by doing this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
void displayID(string array[], int& cnt)
{
int count = 0;
int i;
int num = 0;
cout << "Student ID numbers on file are: " << endl;
for (count = 0; count < cnt; count++)
{
cout << array[count] << setw(11);
if ((count % 5)==4)
cout << setw(0) << endl;
}
return;
}
|
Topic archived. No new replies allowed.