0

1.

int _tmain(int argc, _TCHAR* argv[])

2.

wprintf(L" ----------\n");

This is syntax that I get when I make any Win32 Console Application in Visual C++.
I cannot understand what are _tmain(), argc, _TCHAR* argv[]. Till now I have been dealing with void main() and int main().
I also want to know what is 'wprintf' and 'L' in that second line of code.

Please help !!!
Thanx ... !
:)

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Narue
1

_TCHAR is typedef'd as 'char' when your project uses 'ANSI' settings, it is typedef'd as 'WCHAR' when your project is unicode.

wprintf is just like printf, but instead it takes a const WCHAR* as input, not a const char*.

L before a string literal ("string") tells the compiler that this is a UNICODE string. Without the L you would get an error 'no acceptable conversion from const char* to const WCHAR*', as then the compiler would treat " ----------\n" as an ANSI string.

Btw, you should never deal with void main, main should always return an int.

0

This is syntax that I get when I make any Win32 Console Application in Visual C++.

When writing standard C++, I always start with an empty project. That way I don't have to undo all of the Microsoftisms to make my code portable. But all of the T* stuff is simply Microsoft's way of handling both wide and narrow character types without significant changes to the code. It's not a bad idea, but it also ties you down a bit in terms of code portability.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.