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

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -