How can I process command line arguments in c++? [closed]

  argc, argv, c++, command-line

I need to write a program that receives an executable file path as the first argument, check if the the file exists and that it is executable.

#include <iostream>

using namespace std;

int main (int argc, const char * argv[]){ 
    cout << "# Arguments:  " << argc << endl;

    for (int i = 0; i < argc; ++i) {
        cout << argv[i] << endl;
    }

    return 0;
}

This is what I have but I dont know how to process the arguments (argv[]) to do that?

Source: Windows Questions C++

LEAVE A COMMENT