title: Why would I get a syntax error near unexpected token? Command line arguments?
body: <p>Here is the code I have- not sure why I am getting this error message:</p>
  
  <pre><code>$ ./main.cpp "hello" "is"
  ./main.cpp: line 4: syntax error near unexpected token `('
  ./main.cpp: line 4: `int main(int argc, char *argv[]){'
  </code></pre>
  
  <p>It compiles fine in g++, but when I run it, I get the above error. Any idea why? Here is my complete code..</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  int main(int argc, char *argv[]){
  
      for(int i = 0; i &lt; argc; i++){
          std::cout &lt;&lt; argc &lt;&lt; " : " &lt;&lt; argv[i] &lt;&lt; '\n';
      }
  
      if (argc != 2){
          std::cout &lt;&lt; "\nUSAGE: 2 command line arguments please." &lt;&lt; std::endl;
          std::cout &lt;&lt; "\n   (1) Input file with raw event scores.\n   (2) Output file to write into.";
      }
  
    // open the font file for reading
      std::string in_file = argv[1];
      std::ifstream istr(in_file.c_str());
      if (!istr) { 
          std::cerr &lt;&lt; "ERROR: Cannot open input file " &lt;&lt; in_file &lt;&lt; std::endl;
    }
  
      return 0; 
  }
  </code></pre>