I have a program:
int _tmain(int argc, char* argv[])
{
std::cout << "STARTING" << std::endl;
std::cout << "Num inputs: " << argc << std::endl;
for(int i = 0; i < argc; i++)
std::cout << argv[i] << std::endl;
that I expect to print out all the command line arguments. However, the output is this:
./Test.exe hello world
STARTING Num inputs: 3 . h w
It appears that it's only looking at the first char in each argument and not the entire char* till termination character.
Anyone have any thoughts?
Additional Notes: Creating it through VS2008, and I am essentially copying and pasting an example on the internet that should work. I have run the program in bash, powershell, and cmd.
Your Visual C++ project is set to Unicode, and your main function is called _tmain. This means that Windows invokes your function and passes you Unicode strings, but you're treating them as ANSI strings by using the char* type. Since the second byte of the first Unicode character is null, this appears as an ANSI string with one character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With