By default, it _tmainaccepts Unicode strings as arguments, but coutexpects ANSI strings. This is why it prints only the first character of each line.
If you want to use Unicode _tmain, you must use it with TCHARand wcoutas follows:
int _tmain(int argc, TCHAR* argv[])
{
for (int c = 0; c < argc; c++)
{
wcout << argv[c] << " ";
}
return 0;
}
ANSI, main char cout :
int main(int argc, char* argv[])
{
for (int c = 0; c < argc; c++)
{
cout << argv[c] << " ";
}
return 0;
}
: TCHAR _tmain Unicode ANSI, . UNICODE , , Unicode. UNICODE , ANSI. , Unicode ANSI- - , .
cout (ANSI) wcout (Unicode). _tcout . :
#if defined(UNICODE)
#define _tcout wcout
#else
#define _tcout cout
#endif
int _tmain(int argc, TCHAR* argv[])
{
for (int c = 0; c < argc; c++)
{
_tcout << argv[c] << " ";
}
return 0;
}