title: Assigning memory to double pointer?
body: <p>I am having trouble understanding how to assign memory
  to a double pointer.
  I want to read an array of strings and store it.</p>
  
  <pre><code>    char **ptr;
      fp = fopen("file.txt","r");
      ptr = (char**)malloc(sizeof(char*)*50);
      for(int i=0; i&lt;20; i++)
      {
         ptr[i] = (char*)malloc(sizeof(char)*50);
         fgets(ptr[i],50,fp);
      }
  </code></pre>
  
  <p>instead of this I just assign a large block of memory and 
  store the string</p>
  
  <pre><code>  char **ptr;
    ptr = (char**)malloc(sizeof(char)*50*50);
  </code></pre>
  
  <p>would that be wrong? And if so why is it?</p>