I've been trying to get this stupid function to work for days and just cannot get it.
My display looks like this:
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
All I want it to do is have those last 4, 5, 6, and 7 wrap around to the next column. I've tried inserting "\n" different places, but cannot get it to work properly. Can anyone lend me any insight?
void displayTable(int numDays, int offset)
{
//Declare Variables
int days;
int colCount = 0;
//List the day headings
cout << " Su Mo Tu We Th Fr Sa\n";
//Offset
if (offset == 0)
cout << setw(4) << " ";
else if (offset == 1)
cout << setw(8) << " ";
else if (offset == 2)
cout << setw(12) << " ";
else if (offset == 3)
cout << setw(16) << " ";
else if (offset == 4)
cout << setw(20) << " ";
else if (offset == 5)
cout << setw(24) << " ";
else (offset == 6)
;
//Displays number of days
for (days = 1; days <= numDays; days++)
{
cout << " " << setw(2) << days;
if (days % 7 == 0)
cout << "\n";
}
if (colCount == 7)
{
cout << endl;
colCount = 0;
}
return;
}