ASSIGNING VALUES TO STRUCTURE ELEMENTS
To assign todays date to the individual elements of the structure
todays_date, the statement
todays_date.day = 21; todays_date.month = 07; todays_date.year = 1985;
is used. NOTE the use of the .element to reference the individual elements within todays_date.
/* Program to illustrate a structure */ #include <stdio.h> struct date { /* global definition of type date */ int month; int day; int year; }; main() { struct date today; today.month = 10; today.day = 14; today.year = 1995; printf("Todays date is %d/%d/%d.\n", \ today.month, today.day, today.year ); }
CLASS EXERCISE C21
Write a program in C that prompts the user for todays date,
calculates tomorrows date, and displays the result. Use
structures for todays date, tomorrows date, and an array to hold
the days for each month of the year. Remember to change the month
or year as necessary.