fork download
  1. #include <stdio.h>
  2.  
  3.  
  4. /* Its OK to make the type global, that way all functions can use it */
  5. /* Note that "struct date" is NOT a global variable */
  6. struct date
  7.  
  8. {
  9.  
  10. int month;
  11.  
  12. int day;
  13.  
  14. int year;
  15.  
  16. };
  17.  
  18. void printNextDay (struct date dateval); /* function prototype */
  19.  
  20.  
  21. int main ()
  22. {
  23. struct date today; /* local variable to main */
  24.  
  25. /* Set up a date to pass to the printNextDay function */
  26. today.day = 3;
  27. today.year = 2026;
  28. today.month = 2;
  29.  
  30. /* pass by value the information to our function*/
  31. printNextDay (today);
  32.  
  33. /* The value of today will be unchanged - still the 17th */
  34. printf ("%d/%d/%d \n", today.month, today.day, today.year-2000);
  35.  
  36.  
  37. return (0);
  38.  
  39. } /* main */
  40.  
  41. /**************************************************************************
  42. **
  43. ** Function: printNextDay
  44. **
  45. ** Description: Simply prints the next day of a given 20th century date
  46. ** in MM/DD/YYYY format. Does not check for last day in the month (known
  47. ** issue to be addressed in the future)
  48. **
  49. ** Parameters: dataval - a structure with month, day, and year
  50. **
  51. ** Returns: void
  52. **
  53. **********************************************************************/
  54.  
  55. void printNextDay (struct date dateval)
  56. {
  57.  
  58. ++dateval.day; /* add a day to the value passed into this function */
  59.  
  60. printf ("%d/%d/%d\n", dateval.month, dateval.day, dateval.year-2000);
  61.  
  62. return; /* optional, no value returned since it returns void */
  63.  
  64. } /* printNextDay */
  65.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
2/4/26
2/3/26