Reputation: 8941
I want to make an array of 20 strings (char*
) where each of them is allocated automatically length of MAXLENGTH
will by saying:
char *string_arr[MAXLENGTH][20];
I'll be able to address each string as string_arr[i]
where 0=<i<20
and more importantly, will I be able to put things into string_arr[i]
without dynamically allocating memory, e.g:
strcpy(string_arr[2],"some string");
?
Upvotes: 1
Views: 616
Reputation: 2259
Instead of
char *string_arr[MAXLENGTH][20];
Say:
char string_arr[20][MAXLENGTH];
You also probably want to say MAXLENGTH+1
for null termination.
Upvotes: 5