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. { {2,1,1988}, {3,39,10} }, // first date, then time values
  23. { {5,6,1989}, {3,56,20} },
  24. { {8,5,1996}, {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. printf ("\nDate:\t %i/%i/%i\n",
  34. event[i].sdate.month,
  35. event[i].sdate.day,
  36. event[i].sdate.year);
  37.  
  38. printf ("Time:\t %i hour(s) %i minute(s) %i second(s)\n",
  39. event[i].stime.hour,
  40. event[i].stime.minutes,
  41. event[i].stime.seconds);
  42. }
  43. return (0);
  44.  
  45. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
Date:	 2/1/1988
Time:	 3 hour(s) 39 minute(s) 10 second(s)

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

Date:	 8/5/1996
Time:	 6 hour(s) 40 minute(s) 44 second(s)