title: How to dynamically initialize a 2D array in C?
body: <p>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:</p>
  
  <pre><code>char* i; 
  printf("\n\nHow many characters? ");  //takes input from user
  scanf("%d",&amp;num);
  i = new char[num];
  </code></pre>
  
  <p>This worked.</p>
  
  <p>Now when I do the same for 2D Arrays, it doesn't work. How to do it?</p>
  
  <pre><code>char* i; 
  int numOfStrings,maxSize;       
  printf("How many strings do you want to enter? ");
  scanf("%d",&amp;numOfStrings);
  printf("What is the max size of the strings? ");
  scanf("%d",&amp;maxSize);
  
  i = new char[numOfStrings][maxSize];    
  </code></pre>