i am writing a simple program and would like to use the strlen function to get the size of the string in question.
Then i would like to create an array for example testarray[strlen(somestring)];
But it cannot compile, the error says "error: variable-sized object may not be initialized".
However, the length of that string will not change so i guess i have to tell my machine that somehow.
I have only access to these headers.
stdio.h string.h
Would be great if somebody could drop some knowledge bombs. :)
edit: I was wrong testarray[strlen(somestring)]; can compile but testarray[strlen(somestring)] = {}; cannot. With testarray[strlen(somestring)]; i have garbage if i try to use it.
Thanks guys, it is working now with memset!