December 2013
Beginner
576 pages
16h 4m
English
You have seen how to define a pointer to point to a basic data type such as an int or a char. But you can also define a pointer to point to a structure. Earlier in this chapter, you defined your date structure as follows:
struct date{ int month; int day; int year;} ;
Just as you defined variables to be of type struct date, as in
struct date todaysDate;
you can define a variable to be a pointer to a struct date variable:
struct date *datePtr;
You can then use the variable datePtr, as just defined, in the expected fashion. For example, you can set it to point to todaysDate with the following assignment statement:
datePtr = &todaysDate;
After such an assignment, you can indirectly access any of the members of the ...
Read now
Unlock full access