/* Find all Friday The 13th birthdays for person born Nov 13, 1973 */ #include #include int main( void ) { const int FRIDAY = 6 - 1; /* Sunday Is 0, etc... */ struct tm theTime = { 0 }; /* Set all fields To 0 */ int year; theTime.tm_mon = 11 - 1; /* January is 0, etc... */ theTime.tm_mday = 13; /* 13th day of the month */ for( year = 1973; year < 2073; year++ ) { theTime.tm_year = year - 1900; /* 1900 is 0, etc... */ if( mktime( &theTime ) == -1 ) { printf( "mktime failed in %d\n", year ); break; } if( theTime.tm_wday == FRIDAY ) printf( "%s", asctime( &theTime ) ); } return 0; }