H
Harsha_MR
Guest
I have a need to convert command line argument to integer and when i do that with using CommandLineToArgvW API I dont get correct value. What could be in the code below..?
int main(int argc,char *argv[])
{
LPWSTR *LPWSTR_argv = CommandLineToArgvW(GetCommandLine(), &numArgs);
int User_Input_value = 0;
//This Does not work and gives the value "3" but provided in command line argument is "33".
User_Input_value = atoi(reinterpret_cast<char*>(LPWSTR_argv[1]));
//This works and gives the value "33" provided in command line argument
User_Input_value = atoi(argv[1]);
}
When I see the memory data for argv, it shows that 1st and 2nd command line argument are fine..
\Context.exe.33
But when I see memory data for LPWSTR_argv, after every character in the command line input there is NULL..
\.C.o.n.t.e.x.t...e.x.e...3.3
Continue reading...
int main(int argc,char *argv[])
{
LPWSTR *LPWSTR_argv = CommandLineToArgvW(GetCommandLine(), &numArgs);
int User_Input_value = 0;
//This Does not work and gives the value "3" but provided in command line argument is "33".
User_Input_value = atoi(reinterpret_cast<char*>(LPWSTR_argv[1]));
//This works and gives the value "33" provided in command line argument
User_Input_value = atoi(argv[1]);
}
When I see the memory data for argv, it shows that 1st and 2nd command line argument are fine..
\Context.exe.33
But when I see memory data for LPWSTR_argv, after every character in the command line input there is NULL..
\.C.o.n.t.e.x.t...e.x.e...3.3
Continue reading...