Chapter
Selection Operators
From ComputerScienceOne by Dr Chris Bourke
Concepts
- How do you dynamically allocate and initialize a structure?
"Student *s = (Student *) malloc(sizeof(Student) * 1); The multiplication by 1 in this example is not strictly necessary, but emphasizes the fact that we are allocating space for one structure and not
- How do you access members of a statically declared structure?
"Once we have a declared structure, we need to access its member variables and perhaps update them. If we have a statically declared structure, such as Student s; we can use the direct component selec
- How do you access members through a pointer to a structure?
"When we have a pointer to a structure, we cannot directly use the dot operator. Instead, we have to change the pointer into a “normal” structure by dereferencing it, then we can use the dot operator.