title: How to run c program and give input in same line
body: <p>I'm new to C and I'd like to ask about running a C program and supplying input at the same time.</p>
  
  <p>What I would like to do is run a program (ex. fileOpener) and also state which file to open</p>
  
  <pre><code>./fileOpener &lt; filename1
  </code></pre>
  
  <p>I've tried it already and it works fine, but what do I use to know what filename1 is? That way I can open the file with</p>
  
  <pre><code>fp = fopen(filename1, "r")
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>Edit: OK, I'll try to explain a bit more. If there wasn't a "&lt;" then I could just use command line arguments as I have done before, but when I tried it with the &lt;, it didn't work</p>
  
  <p>Specifically: fileOpener code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(int argc, char *argv[]){
  printf("%s", argv[1]);
  }
  </code></pre>
  
  <p>when I use <code>./fileOpener &lt; filename1</code> the output is <code>./fileOpener</code></p>
  
  <p>I used <code>gcc -o fileOpener fileOpener.c</code> as the compiler</p>