title: Read integer line by line in c
body: <p>I know it's asked before, but I haven't found for what I was searching for.</p>
  
  <p>I have a text document that have:</p>
  
  <pre><code>1 2 3 .
  2 3 4 5
  3 1 2 .
  </code></pre>
  
  <p>and i have 4 arrays that I need to put each number on the line in one of them<br>
  here's my code</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
    FILE *file = fopen("d:\\rf.txt", "r");
    int ch[3];
    int a[3],b[3],c[3];
    int z,x,t,v,i;
    if (file  == NULL) return 1;
    for(i=1;i&lt;=3;i++)
    {
        fscanf(file,"%d %d %d %d",&amp;z,&amp;x,&amp;t,&amp;v);
        ch[i]=z;
        a[i]=x;b[i]=t;c[i]=v;
        printf("%d %d %d %d\n",ch[i],a[i],b[i],c[i]);
    }
  
    return 0;
  }
  </code></pre>
  
  <p>that's what I get:</p>
  
  <pre><code>1 2 3 0
  1 2 3 0
  1 2 3 0
  </code></pre>
  
  <p>Thanks </p>