title: segmentation fault in during dynamic memory allocation with malloc
body: <p>This might be very silly question to ask.<br>
  I am using malloc to memory allocation.<br>
  Program compiles fine but segmentation fault occurs while launching.<br>
  Here is min code:  </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      int row,col,i;
      int **mat;
      row = 3; //made row as static for testing
      col = 4; //made col as static for testing
      *mat = (int *)malloc(sizeof(int)*row);
      for (i=0;i&lt;row;i++)
         mat[i] = (int *) malloc (sizeof(int)*col);
  }
  </code></pre>
  
  <p>i compiled with: gcc -ggdb test.c<br>
  on gdb its giving:  </p>
  
  <pre><code>(gdb) run
  Starting program: /slowfs/swe91/abjoshi/clients/fw_cl_for_seg_fault/a.out
  
  Program received signal SIGSEGV, Segmentation fault.
  0x00000000004004cc in main () at 1test.c:10
  10          *mat = (int *)malloc(sizeof(int)*row);
  </code></pre>
  
  <p>Note: gcc version 4.5.2</p>