Dates & things in C

mcdonald at uxe.cso.uiuc.edu mcdonald at uxe.cso.uiuc.edu
Wed Jun 7 00:18:00 AEST 1989


>
>    #ifdef AMERICA
>        sprintf(Buffer, "%s-%02d-%02d", MonthStr, Date, Year);
>    #else /* BENIGHTEDPARTSOFWORLD */
>        sprintf(Buffer, "%02d-%s-%02d", Date, MonthStr, Year);
>    #endif
>

NO NO NO NO NO NO!!!!!!!!!!

PLEASE:

    #ifdef AMERICA
        sprintf(buffer, "%s-%02d-%04d",monthstring[month], date, year);
    #else /*Pretty soon all your oxygen will come from the forests of
           North America! */
        sprintf(buffer, "%02d-%s-%04d",date,monthstring[month],year);
    #endif  /*                     ^          
                                   ^
                                   ^
                                   ^   */ 

Note the "4"!!!!

Doug McDonald



More information about the Comp.lang.c mailing list