title: C fscanf jump values
body: <p>I'm trying to make a program to read the values ​​in a file and prints them on the screen, now in part to print the files that my program ends up skipping some values​​. Another question, how would I do to allocate memory dynamically for v in this case?</p>
  
  <p>file:</p>
  
  <pre><code>3 -1 1 3 1 
  2 2 1 -3.4 
  5 -1 -2 5 0 -3 1 
  </code></pre>
  
  <p>code:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  #define N 100
  
  int main(){
  float *v;
  int i=0;
  
  v=(float*)malloc(N*sizeof(float));
  
  FILE* fp;
  fp = fopen("entrada.txt","rt");
  if (fp == NULL) {
  printf("Erro na abertura do arquivo!\n");
  exit(1); }
  
  do{
  fscanf(fp," %f",&amp;v[i]);
  printf("v[%d] = [%f]\n",i,v[i]);
  i++;
  }
  while ((fscanf(fp," %f",&amp;v[i])) != EOF);
  
  int fclose (FILE* fp);
  system("pause");
  return 0;
  }
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>v[0] = [3.00000]
  v[1] = [1.00000]
  v[2] = [1.00000]
  v[3] = [2.00000]
  v[4] = [-3.00000]
  v[5] = [-1.00000]
  v[6] = [5.00000]
  v[7] = [-3.00000]
  v[8] = [1.00000]
  </code></pre>