previous | index | next

Using typedefs

However, we need to make corresponding changes to the code that uses the struct:

gameStateInfo stateInfo;      // declare the struct and
gameState state = &stateInfo; // a pointer to it

state->pile1 = 5;
state->pile2 = 8;
clear(state);                 // note absence of '&'

assert(state->pile1 == 0 && state->pile2 == 0);


previous | index | next