title: .open files using argc and argv in C++
body: <p>I have some code Which is supposed to open two .dat file at the same time and eventually load the files over to a method to deal with them. I am not sure how to load the two files in using the code I have been given. I will show below.</p>
  
  <p>This is my main</p>
  
  <pre><code>int main(int argc, char** argv)
  {
  // Start main class with command-line args
  
  
  
  GPXport run(argc, argv);
  return 0; 
  }
  </code></pre>
  
  <p>This is the code part to load in the files.</p>
  
  <pre><code>ofstream output;
  
  // Open files
  file_one.open(argv[1]);
  file_two.open(argv[2]);
  output.open(argv[3]);
  
  if (! file_one) {
      cout &lt;&lt; "Error reading: " &lt;&lt; argv[1] &lt;&lt; endl;
  } else if (! file_two) {
      cout &lt;&lt; "Error reading: " &lt;&lt; argv[2] &lt;&lt; endl;
  } else if (! output) {
      cout &lt;&lt; "Error creating: " &lt;&lt; argv[2] &lt;&lt; endl;
  } else {
      cout &lt;&lt; "Master: " &lt;&lt; argv[1] &lt;&lt; endl &lt;&lt;
              "Slave: " &lt;&lt; argv[2] &lt;&lt; endl &lt;&lt;
              "Output file: " &lt;&lt; argv[3] &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Now the problem is, I do not understand the argv and argc situation. How do i get the two file locations to this code?</p>
  
  <p>Thanks</p>
  
  <p>Edit---</p>
  
  <p>I also have this before the second part of the code..</p>
  
  <pre><code> GPXport::GPXport(int argc, char **argv)  
   {
  using namespace std;
  if (argc != 4) {
      cout &lt;&lt; "Usage: ./gpsfix_cpp &lt;master&gt; &lt;slave&gt; &lt;output&gt;" &lt;&lt; endl;
      exit(1);
    }
  </code></pre>