Command Line Argument Comparison
Hmm, I'm having some trouble with this.
I want to check if the second argument (argv[1]) is equal to "-debug".
so what I've done is...well, see below. None of the if statements register as true.
Code:
char *debugArg = argv[1];
if (debugArg == "-debug")
if (debugArg == "-debug\0")
if (debugArg == "-debug\n")
None of them work! The middle one with the \0 should...I tested it manually to make sure that letter was a \0, and it is. What's wrong with this?
The only solution I have right now is, unfortunately,:
Code:
if (debugArg[0] == '-' &&
debugArg[1] == 'd' &&
debugArg[2] == 'e' &&
debugArg[3] == 'b' &&
debugArg[4] == 'u' &&
debugArg[5] == 'g')
...but that kinf of sucks. What's the solution to this? Maybe I could use strings somehow...
--Ashiq