fork download
  1. struct time
  2. {
  3. int hour, minutes, seconds;
  4. };
  5.  
  6. struct date
  7. {
  8. int month, day, year;
  9. };
  10.  
  11. struct date_and_time
  12. {
  13. struct date sdate; /* stores date values */
  14. struct time stime; /* stores time values */
  15. };
  16.  
  17. #include <stdio.h>
  18. int main ( )
  19. {
  20. struct date_and_time event [3] =
  21. {
  22. { {11,29,1995}, {3,39,10} }, /* first date, then time values */
  23. { {2,21,2000}, {3,56,20} },
  24. { {4,15,2002}, {6,40,44} }
  25. };
  26.  
  27. event [1].sdate.month = 10; /* change a month value */
  28.  
  29. ++event [1].stime.seconds; /* Add one second */
  30.  
  31. for (int i=0; i < 3; ++i)
  32. {
  33.  
  34. printf ("\nDate:\t %i/%i/%i\n",
  35. event[i].sdate.month,
  36. event[i].sdate.day,
  37. event[i].sdate.year);
  38.  
  39.  
  40. printf ("Time:\t %i hour(s) %i minute(s) %i second(s)\n",
  41. event[i].stime.hour,
  42. event[i].stime.minutes,
  43. event[i].stime.seconds);
  44. }
  45.  
  46. return (0);
  47. }
  48.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Date:	 11/29/1995
Time:	 3 hour(s) 39 minute(s) 10 second(s)

Date:	 10/21/2000
Time:	 3 hour(s) 56 minute(s) 21 second(s)

Date:	 4/15/2002
Time:	 6 hour(s) 40 minute(s) 44 second(s)