I'm quite new to Visual C++ so this might be a 'schoolboy' error, but the following code is not executing as I'd expected:
#include "stdafx.h"
#include <string.h>
int _tmain(int argc, _TCHAR* argv[])
{
if (strcmp((char*)argv[1], "--help") == 0)
{
printf("This is the help message."); //Won't execute
}
return 0;
}
The executable, named Test.exe
is launched as follows
Test.exe --help
I was expecting the message This is the help message.
but I'm not seeing it - debugging reveals that the if
condition comes out as -1 and not 0 as I'd expect. What am I doing wrong?