1

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.

This is my main

int main(int argc, char** argv)
{
// Start main class with command-line args



GPXport run(argc, argv);
return 0; 
}

This is the code part to load in the files.

ofstream output;

// Open files
file_one.open(argv[1]);
file_two.open(argv[2]);
output.open(argv[3]);

if (! file_one) {
    cout << "Error reading: " << argv[1] << endl;
} else if (! file_two) {
    cout << "Error reading: " << argv[2] << endl;
} else if (! output) {
    cout << "Error creating: " << argv[2] << endl;
} else {
    cout << "Master: " << argv[1] << endl <<
            "Slave: " << argv[2] << endl <<
            "Output file: " << argv[3] << endl;
}

Now the problem is, I do not understand the argv and argc situation. How do i get the two file locations to this code?

Thanks

Edit---

I also have this before the second part of the code..

 GPXport::GPXport(int argc, char **argv)  
 {
using namespace std;
if (argc != 4) {
    cout << "Usage: ./gpsfix_cpp <master> <slave> <output>" << endl;
    exit(1);
  }
NJD
  • 197
  • 1
  • 4
  • 17

1 Answers1

1

Run compiled executable from command line as:

[your executable] [input path1] [input path2] [output path]

if any path contains spaces quote the path.

Andriy Tylychko
  • 15,967
  • 6
  • 64
  • 112
  • I am trying to find my executable project from netbeans. – NJD Jul 24 '14 at 12:35
  • http://stackoverflow.com/questions/9672072/netbeans-ide-for-c-how-to-specify-command-line-arguments your executable is in "${OUTPUT_PATH}" – willll Jul 24 '14 at 12:48