1int main(int argc, char * argv[]) {
2
3 if (argv[1] == "yes"); // Wrong, compares two pointers
4 if (strcmp(argv[1], "yes") == 0); // This compares what the pointers point to
5 if (std::string(argv[1]) == "yes"); // Works fine
6 if (argv[1] == std::string("yes")); // Works fine
7
8 // Easy-mode
9 std::vector<std::string> args(argv, argv+argc);
10 for (size_t i = 1; i < args.size(); ++i) {
11 if (args[i] == "yes") {
12 // do something
13 }
14 }
15
16}