declare array once C -


if have function called lot of times, , function needs array of 16 pointers updated new pointers every time it's called, right way declare array?

char** readuserinput() {     static char* cmds[16];     ...  } 

will array initialized once?

yes, static variables initialized once. declaring variable cmds declaring array of 16 char*s. array initialized zeroes. array never initialized again.

take code example:

int i; static char *cmds[5]; (i = 0;i<5;++i) {   printf("%d ", cmds[i]); } 

it prints:

0 0 0 0 0


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -