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

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -