// this is the main entry point for our program...
int main(int argc, char* argv[]) {
std::cout<< "make sure to type -ex"<<endl;
if (argc < 5) { // Check the value of argc. If not enough parameters have been passed, inform user and exit.
std::cout << "Usage is -in <infile> -out <outdir>\n"; // Inform the user of how to use the program
std::cin.get();
exit(0);
} else { // if we got enough parameters...
char* myFile;
char* myPath; // here is where I changed.
char* myOutPath;
char* extractt;
char* reimportt;
std::cout << argv[0];
for (int i = 1; i < argc; i++) { /* We will iterate over argv[] to get the parameters stored inside.
* Note that we're starting on 1 because we don't need to know the
* path of the program, which is stored in argv[0] */
if (i + 1 != argc) // Check that we haven't finished parsing already
if (argv[i] == "-f") {
// We know the next argument *should* be the filename:
myFile = argv[i + 1];
} elseif (argv[i] == "-p") {
myPath = argv[i + 1];
} elseif (argv[i] == "-o") {
extractt = argv[i + 1];
}elseif (argv[i] == "-ex") {
myOutPath = argv[i + 1]; // I added this new
}elseif (argv[i] == "-re") {
reimportt = argv[i + 1]; // I added this new
} else {
std::cout << "Not enough or invalid arguments, please try again.\n";
Sleep(2000);
exit(0);
}
std::cout << argv[i] << " ";
}
//... some more code
std::cin.get();
return 0;
}
So what have I changed?
I changed the char* myFile, myPath, myOutPath;
To char* myFile;
char* myPath;
char* myOutPath;
This way you can have no errors which are a few from this method or approach.
I also added 2 new commmands -ex -re for reimport and extract...
Hi, welcome to the forum. Please use code formatting... edit your post and put [code] and [/code] around your code.
Yes, whoever wrote that wrote it wrong. Although the program is still wrong. And honestly, it looks messy and modern C++ doesn't need to use raw pointers that often.