Trying to output a calendar month next to the first, not under

I'm trying to create a year calendar but it has to be 3 across and 4 down, is there a term that i can use instead of endl that will move the cursor to the top and right after i print the last day in each month?

https://campus.fsu.edu/@@/323B2DE642FDAD5328A5B924116A3FEC/courses/1/COP3014.sp12.web_cohort1/content/_4807431_1/Assignment4.pdf

the example is at the end, if a visual helps.
Last edited on
A visual would help, but FSU requires me to log in with my student ID to access content.
I was afraid that would happen. http://www.labtestproject.com/files/linuxcmd/a_year_cal.gif
It pretty much has to look like that, and my code right now just has the months under each other.
FIRST: why on earth are you running as root? Knock it off.

Now to the project. It is safe to assume that your output will go to an 80-column display. Smaller displays are rare, and larger ones will still look fine with only 80-column output. That output looks like it is 66 characters wide -- well within the display frame.

The way to do it is to assemble the output in memory before printing it to the display.

Two methods suggest themselves to me:

1. Print three calendars each to an array of 8 rows, 20 characters. (That is, have three arrays that each receive a calendar to print, in order, e.g. "January", "February", and "March".

Once done, print the three arrays by splitting off the top line for each, the second line for each, and so one, until there are no more lines left.

Lather, rinse, and repeat, until no more months.

Notice that you will have to be careful to account for whether or not a month uses 7 or 8 lines.

2. Print three calendars to a single array of 8 rows, 66 characters. This requires your calendar print routines to know how to print to an offset in the array. You still need to account for the maybe-8th line.

Print the array as a whole. Repeat until no more months.

I recommend method 1, since it will make your calendar print routines much simpler, and printing three calendars together is easy.

Hope this helps.
Running as root? I don't know what you mean. And I was hoping I wouldn't have to completely overhaul all of my code and make a bunch of new arrays, but rather tell the cursor to return to the top after it prints each month unless it's April,July,or October.
Er, sorry, the person who made that image was moronically running as root... Sorry.

As for the cursor thing, it is possible -- easy even -- but you are really much better off just doing it the Right Way. You'll learn more; you'll be happier with the result; you'll have less weird stuff to worry about; and your program will be more flexible. Just make the extra array(s).

Hope this helps.
Seems to me that it would end up being a lot of hard coding, whereas this program is supposed to be able to take any year that is input to it and print the calendar. I was hoping I could steer more towards using loops to keep it flexible. Thanks for all your help by the way, I'm sorta new to this stuff.
The first method I suggested to you is the easiest way you will find to do it of the three we have discussed, and the most flexible -- though I don't see you using the additional flexibility in this particular program.

Every part of it uses loops.
Just to make sure i'm understanding, youre saying make an array like Firstrow[8] then Firstrow[1] would be the months, Firstrow[2] would be the first row of numbers in the months, etc?
No, make a 2d array type just big enough to write one of the calendars to it.

Create three of those arrays, and write the first three months - January to the first array, February to the second, and March to the third.

Then, pass those three arrays to a function which will print the first row of each array to the display (using cout) -- all on the same line, of course. Then the next row of each array gets printed to the next line of the display. And so on.

Once done, you can do the same thing for April, May, and June.
Repeat for July, August, and September.
Repeat for October, November, and December.

Does this make sense? (Or did I not explain something well enough or leave something out?)
Topic archived. No new replies allowed.