It won't allow me to initialize the array to NULL in the struct in the header file:
typedef struct frog
{
bool is_frog;
struct frog* french_chef[10]; // eg = {NULL};
} frog;
which I get, but it also won't let me do it in the main function:
frog* root = malloc(sizeof(frog));
root->french_chef = {NULL};
Where is my logic error? I'd like to learn what I'm confused about before moving on to correcting it. I've read a few alternatives like memset and calloc, but memset seems inefficient and I'm not confident that calloc assigning zero's to everything will allow me to evaluate for NULL
or \0
in the array later on in main.
calloc()
will initialize your pointers toNULL
don't worry. Or create a for loop that assignsfrench_chef[i] = NULL;
fori
from 0 to 9..calloc()
is faster thatmalloc()
+memset()
.