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