CSC 101 Lecture Notes Week 7
Introduction to C Structures;
Introduction to "Programming in the Large"
Relevant Reading: Chapters 11, 13
typedef struct {
char name[STRSIZ]; /* name of the planet */
double diameter; /* equatorial diameter in km */
int moons; /* number of moons */
double orbit_time; /* years to orbit sun once */
double rotation_time; /* hours to complete one revolution on axis */
} Planet;
101/examples/structs/jupiter.c
defines the type of the field as double, with the name diameter.double diameter
typedef struct {
double diameter; /* diameter of system in km */
Planet planets[9]; /* array of planets */
char galaxy[STRSIZ]; /* name of the system */
} SolarSystem;
101/examples/structs/our-solar-system.c