Dynamic Array of strings [closed]

You can simply use array of n number of pointers to char. Then use a loop to allocate space for those.

int n, size;
scanf("%d %d", &n, &size);
char *arr[n];
for( int i = 0; i < n; ++i ){
    arr[i] = malloc( size * sizeof(char) );
}

Leave a Comment