This question already has an answer here:
- Convert char to TCHAR* argv[] 2 answers
char* stheParameterFileName = argv[1]; //I'm passing the file name as a parameter.
TCHAR szName [512];
How can I convert char*
to TCHAR []
?
This question already has an answer here:
char* stheParameterFileName = argv[1]; //I'm passing the file name as a parameter.
TCHAR szName [512];
How can I convert char*
to TCHAR []
?
Form MSDN:
The definition oft
TCHAR
is depending on whether you are using Unicode or ANSI.See also here:
By using the Tchar.h, you can build single-byte, Multibyte Character Set (MBCS), and Unicode applications from the same sources.
Tchar.h defines macros (which have the prefix _tcs) that, with the correct preprocessor definitions, map to str, _mbs, or wcs functions, as appropriate. To build MBCS, define the symbol _MBCS. To build Unicode, define the symbol _UNICODE. To build a single-byte application, define neither (the default).
By default, _MBCS is defined for MFC applications. The _TCHAR data type is defined conditionally in Tchar.h. If the symbol
_UNICODE
is defined for your build,_TCHAR
is defined aswchar_t;
otherwise, for single-byte and MBCS builds, it is defined as char. (wchar_t, the basic Unicode wide-character data type, is the 16-bit counterpart to an 8-bit signed char.) For international applications, use the _tcs family of functions, which operate in _TCHAR units, not bytes. For example, _tcsncpy copies n _TCHARs, not n bytes.If you include the header file:
Then you can use the A2T macro as below:
Details on MSDN
Your project may be setup to use Unicode. Unicode is for programs that want to handle most languages on planet earth. If you do not need this, go to project properties / general / character set and switch from Unicode to multi-byte.