Try:
https://rubberduckdebugging.com/
OK, from the top of your function:
void displayTable(int getNumDays, int getOffset)
From what I can see above this,
getNumDays and
getOffset are functions; why are you naming them as the function parameters?
Remember: explain this to your rubber duck.
int calcOffset = getOffset + (7 - getOffset);
What are you intending to do with
calcOffset?
Is
calcOffset ever anything other than 7?
Is
calcOffset ever used?
Remember: your rubber duck wants to hear the explanation here.
1 2 3 4 5 6 7 8 9 10 11 12
|
if (getOffset == 0)
cout << setw(4) << " ";
if (getOffset == 1)
cout << setw(8) << " ";
if (getOffset == 2)
cout << setw(12) << " ";
if (getOffset == 3)
cout << setw(16) << " ";
if (getOffset == 4)
cout << setw(20) << " ";
if (getOffset == 5)
cout << setw(24) << " ";
|
How about
cout << setw(4*(getOffset+1)) << " ";
(Your rubber duck is now pointing out that
getOffset wasn't a very good name for a variable.)
1 2
|
if (days % 7 == 0)
cout << endl;
|
Well, you've told it to line feed every 7th day ... so that's precisely what it does. Tell your rubber duck what your really want to do. Go on, try for your initial-line blanks:
cout << setw(4*((getOffset+1) % 7)) << ""; // yes, really empty string
and when you come to force a newline,
if ((days+getOffset+1) % 7 == 0) cout << endl;
(Sorry, your rubber duck is squawking about that
getOffset again).
https://rubberduckdebugging.com/cyberduck/