Yes I did read these two posts.
C compile error: "Variable-sized object may not be initialized" C error "variable-sized object may not be initialized"
My case is a bit different because I'm using char * ptr[buflen]
. This is what I have tried:
char *ptr[buflen] = {0}; //This gave me the variable sized object error.
char *ptr[buflen];
memset( ptr, 0, buflen*buflen*sizeof(char)); //I figured this would work with looking at the previous examples.
//This seemed to work but I am curious if I need to use free or malloc
after looking at the previous examples. I don't want this to seg fault later
in the program and have no clue what is causing it.
char *ptr[buflen];
memset(ptr, 0, sizeof ptr);
char *strings_line_tokens[503] = {0}; //Why does this work but the above won't work?