title: fopen() and command line arguments
body: <p>I'm trying to write a program that will read the first character in a text file. If I use <code>./a.out myfile.txt</code> it works as intended but if I use <code>./a.out &lt;myfile.txt</code> I get <code>Segmentation fault: 11</code>. The reason why I'm trying to include the <code>&lt;</code>is because this what is in the spec of the assignment. The below code is just a simplified example that i've made that has the same issue:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  
  
  int func(int argc, char **argv){
      FILE *fp;
      int test = 0;
      fp = fopen(argv[1], "r");
      fscanf(fp, "%i", &amp;test);
      printf( "current file: %s \n", argv[1]);
  
  
  }
  
  
  int main(int argc, char **argv){
      func(argc, argv);   
  }
  </code></pre>
  
  <p>Is there any way I can get it to accept the argument as <code>&lt;myfile.txt</code>?</p>