c++ - Arguments parsing error -
this question has answer here:
i trying parse run-arguments within console application code:
int _tmain(int argc, _tchar* argv[]) { if(argv[1] == _t("arg1")) cout<<"argument1 passed"; _getch(); return 0; }
my code doesn't work. mean, runs, console empty. compiling use unicode character set
option in visual studio 2012 (on windows 7). mistake?!
use strcmp compare char
arrays
if(strcmp(argv[1], "arg1") == 0)
use of ==
compares pointers 2 different strings.
see darius kucinskas' answer comparing _tchar
arrays
Comments
Post a Comment