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 ... !
:)

_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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.