Hey guys i have to create a program which is based on the unix calendar command which shows the ascii calendar in the format of
example:
March
mon tu wed thu fri sat sun
1 2 3 4 5 6
7 8 etc etc
But the program will run by typing in a month from 0 - 12 , 0 is suppose to be valid because if the user types 0 it will display all months. But if the user types 1 for example it will just display january. But after you have typed in the month you type in the year considering the leap years then it will display the month.
I have done some input for both month and year functions but how will i create teh rest of the algorith could someone explain it very simply please? thnxs
joey
|
Go4Expert Founder
|
![]() |
| 9Mar2006,19:46 | #2 |
|
I have the program ready but would like to give a part of it so that you can work on the main logic and go ahead.
Initialize the variables as Code: C
Code: C
Code: C
Shabbir |
|
Team Leader
|
![]() |
| 9Mar2006,21:47 | #3 |
|
Too fast Shabbir. Well done.
|
|
Go4Expert Founder
|
![]() |
| 9Mar2006,22:35 | #4 |
|
Thanks.
|
|
Go4Expert Member
|
|
| 10Mar2006,06:12 | #5 |
|
thnxs buddy
|
|
Go4Expert Member
|
|
| 10Mar2006,06:19 | #6 |
|
By the way could you explain a little more how that void days function works and how it prints it?
thnxs |
|
Go4Expert Founder
|
![]() |
| 10Mar2006,07:22 | #7 |
|
Simple it checks how many leap years exists between the current year that is passed as parameter and Y.
Then it adds up all the days of the month for the calender year. Then it calculates the days in the year, month and week. Then it displays them all through the display function by getting the array. |
|
Go4Expert Member
|
|
| 10Mar2006,07:31 | #8 |
|
Also can i ask im getting a funny error when im intializing the variable array of months
braces around scalar initializer error Where should i actually intialize the variable in main or in a seperate function because most likely all the other functions would have to use the array ? Code:
int main(void)
{
unsigned int month [] = {{31}, {28}} /* etc etc*/
unsigned long year;
getMonth(&month)
getYear(&year);
return EXIT_SUCCESS;
}
unsigned getMonth(unsigned int *month)
{
}
Just trying to get an idea how it should be designed as well? |
|
Go4Expert Founder
|
![]() |
| 10Mar2006,10:37 | #9 |
|
Its a Global variable. I just did not want to make it passing to all the functions.
Design can always be improved as I have just mad the algo to work. |


