Hi...Im trying to make a date reminder type program...But Im looking for something along the lines of If(date == 31102005){*code*....May I please have help with this?? This is what i did...But is totally wrong...I need something that checks the date...where the user does not enter data.

#include <stdio.h>
#include <windows.h>
#include <time.h>

int main(void)
{
    int day, month, year;

if (day == 31 & month == 10 & year == 2005)
{

system("Echo Happy Halloween!");

}
return(0);
}

see the ansi time() function, decribed in the C time.h header file.


Here is my code, in C :

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

/**retrieves the current date.
  * the given parameters are filled with the current time values
  */
void retrieve_time(int* day, int* month, int *year)
{
    time_t t=time(NULL);
    struct tm* timeinfo=localtime(&t);
    *day=timeinfo->tm_mday;
    *month=timeinfo->tm_mon+1;/*junuary->1 december->12*/
    *year=timeinfo->tm_year+1900;
}

int main(void)
{
      int day, month, year;
      retrieve_time(&day, &month, &year);
      if(day==31 && month==10 && year==2005)
      {
          printf("happy halloween 2005 !\n");
      }
      return EXIT_SUCCESS;
}
commented: -mike555 +1

OMG thank you soo much!!! Is there a way to apply this same principal for time??

Yes, just look at the other members of the tm struct.

commented: -mike555 +1