When a struct that contains an array of struct pointers is instantiated,
am I guaranteed that all pointers in the struct array member will be set to NULL
?
Here's an example struct:
typedef struct mmNode {
int val;
int board[2][NUM_PITS+1];
int side;
struct mmNode* children[NUM_PITS+1];
} mmNode;
IE: If I create an instance of the mmNode struct, will the elements of mmNode.children
always be set to NULL
?
It depends how you initialise your struct.
"Nothing initialized" means that all members will just have random junk values. "Default-initialized" means that all members will be initialized to 0, which for pointer members will be equivalent to
NULL
. "Zero-initialized" means that everything will be set, bitwise, to 0. This will only work on platforms whereNULL
is represented with bitwise 0.