title: Unable to read a file and pass into arguments
body: <p>1) I'm trying to open a file, read the mix data (ints, chars and strings) and store them into args.</p>
  
  <p>1.1) so in the sample.txt is a total of 13 (excluding args[0])</p>
  
  <p>2) Need to read a file from terminal "./myprog.c &lt; sample.txt"</p>
  
  <p>Heres my code and have no idea where i went wrong:</p>
  
  <pre><code>sample.txt:
  123 213 110 90 1
  hello my friend
  boo bleh
  a b c
  </code></pre>
  
  <p>myprog.c:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
          int i = 1;
          FILE *fstin=fopen(argv[0], "r"); //open the file
          if (fstin == NULL) {
              puts("Couldn't fopen..."); 
              return -1;
          }
           //Getting all the inputs from file
          while ((fscanf(fstin, "%d", argv[i])) != EOF){
              i++;
          }
  
          fclose(fstin);
          for (i=0; i&lt;10; i++) {
              printf("%d\n",argv[i]);
          }
  
          return 0;
  }
  </code></pre>
  
  <p>Any help is greatly appreciated!</p>
  
  <p>PS: Would like if anyone could post their complete solution? Will upload unto this post and  let everyone have a review of this problem</p>
  
  <p>PPS: Please excuse the poor level of coding as I am a beginner and completely new to C.</p>