calender

This is a discussion on calender within the C Programming forums, part of the General Programming Boards category; Hey guys could someone give me some steps as to how i could prompt a user to get a particular ...

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    calender

    Hey guys could someone give me some steps as to how i could
    prompt a user to get a particular month on the calender.

    This would eventually print out the days of the month and the name of the month. eg

    user types in month 0 - 12 when asked at the prompt
    0 gets all months and displays them!
    1 gets jan 2 gets feb 3 gets March etc..

    ******* March *******

    sun mon tue wed thu fri sat
    1 2 3 4
    5 6 7 8 9 10 11 etc to end of month

  2. #2
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Quote Originally Posted by bazzano
    Hey guys could someone give me some steps as to how i could
    prompt a user to get a particular month on the calender.
    1. Prompt the user
    2. Output the corresponding month(s).

  3. #3
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252
    How would i get each month ? What sort of functions would i have to use to get each month or a particular month?

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    155
    ok have a function like,

    displaymonth(int i);

    and have an year database which is indexed by the month number.
    need more help? ask.

  5. #5
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252
    ok how can i go about that like for the days would i create some sort of an array for each month?

  6. #6
    Registered User
    Join Date
    Feb 2006
    Posts
    155
    try along these lines:

    Code:
    #include<stdio.h>
    
    
    
    typedef struct {
                       char *name;
                       int start;
                       int ndays;
                   } month;
    
    
    
    
    
    
    display_month(int i,month *m){
    printf("\ns  m  t  w  t  f  s" );
    printf("\n");
    int c= (m+i)->start;
    for(int j=1;j<c;j++)printf("   ");
    for(int j =1;j<=(m+i)->ndays;j++){
    if(j>9)printf("%d ",j); else
    printf("%d  ",j);
    c++;
    if(c==8){c=1;printf("\n");}
     }
    };
    
    
    main(){
    month k[13];
    
    k[1].name ="january";    // for jan
    k[1].start=4;               // jan 1st is a wednesday,wednesday=4
    k[1].ndays=31;             // jan has 31 days
    
    k[2].name="feburary";
    k[2].start=2;            //feb 1 is monday ,monday=2
    k[2].ndays=28;         // feb has 28 days
    
    
    display_month(2,k);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calender..
    By dahenkiz in forum C Programming
    Replies: 2
    Last Post: 11-09-2005, 01:25 PM
  2. Calender
    By sameintheend01 in forum C++ Programming
    Replies: 1
    Last Post: 02-03-2003, 06:36 AM
  3. Replies: 1
    Last Post: 01-29-2002, 02:49 AM
  4. Displaying a calender in this format...
    By Claire in forum C++ Programming
    Replies: 1
    Last Post: 01-28-2002, 04:24 AM
  5. Calender
    By confused in forum C Programming
    Replies: 2
    Last Post: 11-28-2001, 05:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21