I want to make an (2d) array of names using dynamic allocation of memory, where length of each name is 1<=name<=1000000.
I have tried this but this is wrong could you help me
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
int n,i;
char *Names;
scanf("%d",n);
*Names=(char **)malloc(sizeof(char **)*n);
for( i=0;i<n;i++)
(*Names+i)=(char*)malloc(sizeof(char *)*100000);
for(int i=0;i<n;i++)
scanf("%s",Names[i]);
}
return 0;
}
Sample output:
/*
kirito
asuna
pranav
*/