I decided to try my hand at command line parsing and I found a good tutorial here: http://www.cplusplus.com/articles/DEN36Up4/
But I tried to do this:
#include <iostream>
#include <string>
#include <map>
#include <fstream>
using namespace std;
typedef map<string,string> Arguments;
int main(int argc, char** argv)
{
Arguments args;
if(argc < 3)
{
cout << "ERROR: " << endl;
return 1;
}
for(int i = 1; i < argc; i++)
{
string name = string(argv);
if(name == "--Help")
{
if(i + 1 < argc)
{
char* file = argv[i++];
ofstream outfile;
outfile.open(file);
if(outfile.is_open())
{
outfile << "Hello Jesus." << endl;
}
outfile.close();
cout << "File Created: " << endl;
}
}
}
return 0;
}
as you can see, i'm trying to create a file when "--Help" is used (this is just a test, the final command wont be --Help. any ideas?