Date Alert Reminder

Reply

Join Date: Oct 2005
Posts: 10
Reputation: !=logical not is an unknown quantity at this point 
Solved Threads: 0
!=logical not !=logical not is offline Offline
Newbie Poster

Date Alert Reminder

 
0
  #1
Oct 14th, 2005
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.

  1.  
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include <time.h>
  5.  
  6. int main(void)
  7. {
  8. int day, month, year;
  9.  
  10. if (day == 31 & month == 10 & year == 2005)
  11. {
  12.  
  13. system("Echo Happy Halloween!");
  14.  
  15. }
  16. return(0);
  17. }
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 76
Reputation: CrazyDieter is an unknown quantity at this point 
Solved Threads: 3
CrazyDieter's Avatar
CrazyDieter CrazyDieter is offline Offline
Junior Poster in Training

Re: Date Alert Reminder

 
1
  #2
Oct 14th, 2005
see the ansi time() function, decribed in the C time.h header file.


Here is my code, in C :

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4.  
  5. /**retrieves the current date.
  6.   * the given parameters are filled with the current time values
  7.   */
  8. void retrieve_time(int* day, int* month, int *year)
  9. {
  10. time_t t=time(NULL);
  11. struct tm* timeinfo=localtime(&t);
  12. *day=timeinfo->tm_mday;
  13. *month=timeinfo->tm_mon+1;/*junuary->1 december->12*/
  14. *year=timeinfo->tm_year+1900;
  15. }
  16.  
  17. int main(void)
  18. {
  19. int day, month, year;
  20. retrieve_time(&day, &month, &year);
  21. if(day==31 && month==10 && year==2005)
  22. {
  23. printf("happy halloween 2005 !\n");
  24. }
  25. return EXIT_SUCCESS;
  26. }
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 10
Reputation: !=logical not is an unknown quantity at this point 
Solved Threads: 0
!=logical not !=logical not is offline Offline
Newbie Poster

Re: Date Alert Reminder

 
0
  #3
Oct 22nd, 2005
OMG thank you soo much!!! Is there a way to apply this same principal for time??
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Date Alert Reminder

 
1
  #4
Oct 23rd, 2005
Yes, just look at the other members of the tm struct.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC