Published by
Jun 18, 2013

Use of TCHAR in Visual C++

Score: 3.0/5 (107 votes)
*****
You can say TCHAR as "Type + char".

Previously there was only ASCII codes (OR Multi byte character set).

But Now, All programming languages allows coding to be in Unicode for Internationalization Issue.

So Microsoft provided Type T to cover both the types Multibyte character set as well as Unicode character set.
Because there is also exist old code and compiler should compile it based on their character set.

For multibyte character set : TCHAR stands for char (simple character of 1 byte)


For Unicode character set: TCHAR stands for wchar (Wide character of 2 byte)

For example : If your Visual Studio project setting have character set = Multi byte character set
then TCHAR stands for char as in example below,
1
2
3
4
5
6
7
8
#include "windows.h"

int main()
{

TCHAR abc; // just like char abc
return 0;
}



If your Visual Studio project setting have character set = Unicode character set
then TCHAR stands for wchar as in example below,
1
2
3
4
5
6
7
8
#include "windows.h"

int main()
{

TCHAR abc; // just like wchar abc
return 0;
}