1

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");

?

1 Answer 1

5

Instead of

char *string_arr[MAXLENGTH][20];

Say:

char string_arr[20][MAXLENGTH];

You also probably want to say MAXLENGTH+1 for null termination.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.