c - Weird Issue With argv in if statement -
i'm having problems argv in if statement in 1 of c programs. know must missing simple , stupid (it's been while since i've done in c). problem is, won't dootherstuff() if specify nothing else on command line. if ./a.out -i still runs dostuff(). see might missing here? thank lot in advance!
int main(int argc, char *argv[]) if(argv[1] == "-a" || "-a") { dostuff(); } else { dootherstuff(); } }
if want compare strings in c have use methods strcmp: http://www.cplusplus.com/reference/cstring/strcmp/
in c string array of characters, comparing memory address of 2 arrays (which different of course since different arrays).
Comments
Post a Comment