7 Structs
7 Structs
• A single struct would store the data for one object. An array of
structs would store the data for several objects.
makes the name Length a synonym (or alias) for the data type int.
• The data “type” name Length can now be used in declarations in
exactly the same way that the data type int can be used:
Length a, b, len ;
Length numbers[10] ;
Typedef & Struct
• Often, typedef is used in combination with struct to declare a
synonym (or an alias) for a structure:
js.person.id = 123456789 ;
js.person.gpa = 3.4 ;
printf ("%s %ld %f\n", js.name, js.person.id,
js.person.gpa) ;
printf ("%s %ld %f\n", ptr->name, ptr->person.id,
ptr->person.gpa) ;
}