fork download
  1. struct date
  2. {
  3. int month;
  4. int day;
  5. int year;
  6. };
  7.  
  8. /* function prototype */
  9. struct date nextDay (struct date dateval);
  10.  
  11. #include <stdio.h>
  12. int main ()
  13. {
  14.  
  15. /* two structure variables */
  16. struct date today, tomorrow;
  17.  
  18. /* set today to the proper date */
  19. today.day = 17;
  20. today.year = 1996;
  21. today.month = 10;
  22.  
  23. /* This statement illustrates the ability to pass a */
  24. /* structure to a function and to return one as well */
  25.  
  26. tomorrow = nextDay (today); /* tomorrow updated */
  27.  
  28. printf ("%d/%d/%d\n", tomorrow.month,
  29. tomorrow.day,
  30. tomorrow.year-1900);
  31.  
  32. return (0);
  33. }
  34.  
  35. /********************************************************
  36. ** Function: nextDay
  37. **
  38. ** Description: Returns the next day given a date
  39. **
  40. ** Parameters: dateval - a given date
  41. **
  42. ** Returns: dateval - updated next day date
  43. **
  44. *********************************************************/
  45.  
  46. struct date nextDay (struct date dateval)
  47. {
  48.  
  49. ++dateval.day; /* add a day */
  50.  
  51. return (dateval); /* return updated structure */
  52.  
  53. } /* nextDay */
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
10/18/96