title: Trying to format user input (C)
body: <p>My program is designed to take a userinput for a square matrix - i want them to be able to enter each element as it would appear in the matrix. Instead, the program only takes one input and then loops infintely.</p>
  <pre><code>int main()
  {
  int dim;
  
  printf(&quot;Input size of square matrix: &quot;);
  scanf(&quot;%d&quot;, &amp;dim);
  
  int mat[dim*dim];
  
  printf(&quot;Input elements row by row: \n&quot;);
  
  int p;
  int q;
  for (p = 0; p &lt; dim; p++)
  {
      for (q = 0; q &lt; dim; q++)
      {
          scanf(&quot; %d&quot;, mat[dim*p + q]);
      }
      printf(&quot;\n&quot;);
  }
  
  return 0;
  }
  </code></pre>