943,749 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2685
  • C RSS
Oct 14th, 2005
0

Date Alert Reminder

Expand Post »
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. }
Similar Threads
Reputation Points: 33
Solved Threads: 0
Newbie Poster
!=logical not is offline Offline
10 posts
since Oct 2005
Oct 14th, 2005
1

Re: Date Alert Reminder

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. }
Reputation Points: 11
Solved Threads: 6
Junior Poster
CrazyDieter is offline Offline
106 posts
since Jul 2005
Oct 22nd, 2005
0

Re: Date Alert Reminder

OMG thank you soo much!!! Is there a way to apply this same principal for time??
Reputation Points: 33
Solved Threads: 0
Newbie Poster
!=logical not is offline Offline
10 posts
since Oct 2005
Oct 23rd, 2005
1

Re: Date Alert Reminder

Yes, just look at the other members of the tm struct.
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: The Powers Of Two
Next Thread in C Forum Timeline: Time Release Message Box





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC