0

How can I make a memory allocation to the following multi dimensional array?

char* array[NMAX];
1

1 Answer 1

0
#define NMAX 50
char* array[NMAX];

is an array of 50 character pointers.

You have to loop trough all of them and allocate memory for each one.

for( int i = 0 ; i < NMAX ; i++ )
{
    array[ i ] = malloc( sizeof( char ) * 80 ) ;
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.