_tmain is a macro that expand to main o wmain according to _UNICODE macro. In
VC2005, By default , a program is unicode enabled (UNICODE and _UNICODE defined)
so your _tmain macro expands to wmain (not main) and _TCHAR expands to wchar_t.
The problem is that you are using 'cout' (which is prepared to work with
single wide strings) with a double wide string.
// This should work
#include <iostream>
#include <tchar.h>
#ifdef _UNICODE
#define _tcout wcout
#else
#define _tcout cout
#endif
using namespace std;
int _tmain(int argc, _TCHAR *argv[])
{
_tcout <<argv[0]<<endl;
return 0;
}
Regards
--
Cholo Lennon
Bs.As.
ARG
<to********@googlemail.comwrote in message
news:0a**********************************@v4g2000h sf.googlegroups.com...
//int _tmain(int argc, _TCHAR* argv[]) // main for windows
int main(int argc, char *argv[]) // ... or main
{
cout <<argv[0]<<endl;
return 0;
}
//run at command line: test.exe cat dog
With main the output is "test.exe" which I'd expect,
but a similar program using _ tmain outputs a number which I think is
the address of the 't' in test.exe. What is the logic behind this -
what's happening?
Thanks
Tony