mr. Vachovsky
mr. Vachovsky

Reputation: 1128

char * ( 64 bit ( windows 7 ) )

Suppose, that i have the code:

// My.cpp
#include <iostream>

int main( int argc, char ** argv ) 
{
   if ( argc > 1 )
      std::cout << argv[ 1 ] << std::endl;
}

( i use MVSC++ 2008 )

when i run my program in cmd.exe:

My.exe argument

i get this output :

a r g u m e n t 

why?????

Upvotes: 2

Views: 375

Answers (2)

Praetorian
Praetorian

Reputation: 109119

It looks like you're compiling with the Unicode character set option. Go to the project properties and under the General page change to "Use Multi-Byte Character Set". Alternately, if you want to use UTF-16 change the main() function to:

int wmain( int argc, wchar_t **argv )

Also, use std::wcout instead of std::cout to print the arguments.

Upvotes: 1

LostInTheCode
LostInTheCode

Reputation: 1744

Might be a character code problem. Try replacing "std::endl" with "\n" and see. Also, are you compiling as Unicode?

Upvotes: 5

Related Questions