0

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

char* array[NMAX];
TheForbidden
  • 1,533
  • 4
  • 22
  • 30
  • 1
    The answer to this question is in link: [http://stackoverflow.com/questions/4641476/using-dynamic-memory-allocation-for-arrays] – user2071152 Apr 10 '13 at 10:20

1 Answers1

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