c - Initializing a malloc'ed string index to NULL -
for example, created char **strings using malloc.
how set each index strings[i] null? set null? because when check function index equal null, if(strings[i] == null); never seems work. help? sorry i'm new dynamic memory..
null defined macro expands (void *)0
you can use calloc
allocate , initialize zero.
char* buffer = calloc(4, sizeof(char); if(*buffer == 0) { printf("%s\n", "*buffer == 0"); }
Comments
Post a Comment