title: getting input with fgets() in a loop
body: <p>I am trying to take input with <code>fgets()</code>. I know how many lines I will get but it changes and I store the number of lines in the variable <code>var</code>. I also have another variable named <code>part</code>; it is the length of the line I get, but since there are white spaces between the values I multiplied it by 2 (I couldn't find another solution; I could use some advice).</p>
  
  <p>Anyway, I tried to get the input as in the code below, but when I entered the first line it automatically breaks out the <code>for</code> loop and prints random things. I think it is to do with the <code>fgets()</code> in the loop; I don't know if there is a use of <code>fgets()</code> like this.</p>
  
  <pre><code>char inp[var][(2*part)];
  int k,l;
  for(k=0;k&lt;=var;k++);
      fgets(inp[k],(2*part),stdin);
  printf("%c\n",inp[0]);
  printf("%c\n",inp[1]);
  printf("%c\n",inp[2]);
  printf("%c\n",inp[3]);
  </code></pre>