int main (int argc, **argv)
{
if (argv[1] == "-hello")
printf("True\n");
else
printf("False\n");
}
# ./myProg -hello False
Why? I realize strcmp(argv[1], "-hello") == 0
returns true... but why can't I use the equality operator to compare two C strings?
Because argv[1]
(for instance) is actually a pointer to the string. So all you're doing is comparing pointers.