oza*_*yes 9

老实说,我不知道如何使用数组,但有指针​​,微软为我们提供了一些API,如wctombwcstombs.第一个不如第二个安全.所以我认为你可以通过一个数组到指针和一个指向数组的转换来实现你想要实现的目标;

// ... your includes
#include <stdlib.h>
// ... your defines
#define MAX_LEN 100
// ... your codes
// I assume there is no any defined TCHAR array to be converted so far, so I'll create one
TCHAR c_wText[MAX_LEN] = _T("Hello world!");
// Now defining the char pointer to be a buffer for wcstomb/wcstombs
char c_szText[MAX_LEN];
wcstombs(c_szText, c_wText, wcslen(c_wText) + 1);
// ... and you're free to use your char array, c_szText
Run Code Online (Sandbox Code Playgroud)

PS:不是最好的解决方案,但至少它的工作和功能.


Nad*_*LEM 4

TCHAR 是 Microsoft 特定的 typedef,用于或charwchar_t宽字符)。

转换为 char 取决于它实际上是其中的哪一个。如果 TCHAR 实际上是 a char,那么您可以进行简单的转换,但如果它确实是 a wchar_t,您将需要一个例程在字符集之间进行转换。参见函数MultiByteToWideChar()