0

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);
}
3
Contributors
3
Replies
4
Views
12 Years
Discussion Span
Last Post by winbatch
1

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;
}
Votes + Comments
-mike555
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.