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

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?



Read more here: https://stackoverflow.com/questions/66269470/how-can-i-process-command-line-arguments-in-c

Content Attribution

This content was originally published by Zum at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: