Checking Names of Program Arguments

When a user runs my program from the command line, I need the 5th argument to be either "yes" or "no."

So

./program foo bar baz quux yes

or

./program foo bar baz quux no

would be valid, but anything else wouldn't be.

I tried doing a simple if statement like

1
2
3
if (argv[5] != "yes" && argv[5] != "no")
    cout << "Improper arguments.\n";
    exit(0);


But that expression seems to always be false. What expression should I be using instead?
strcmp (from cstring) or convert something to std::string
1
2
if( strcmp(argv[5], "yes")==0 )//equal
if( argv[5] == std::string("yes") )
That worked. Thanks!
Topic archived. No new replies allowed.