So, I'm writing a program in C. I've to do 2 parts of it. one part deals with 1D arrays and the other deals with 2D arrays. THe program requirement is that we enter the size of the arrays through user input. Here's how I did it for the first one:
char* i;
printf("\n\nHow many characters? "); //takes input from user
scanf("%d",&num);
i = new char[num];
This worked.
Now when I do the same for 2D Arrays, it doesn't work. How to do it?
char* i;
int numOfStrings,maxSize;
printf("How many strings do you want to enter? ");
scanf("%d",&numOfStrings);
printf("What is the max size of the strings? ");
scanf("%d",&maxSize);
i = new char[numOfStrings][maxSize];