"_T"有什么用?怎么使用?
解决方案 »
- 另一个问题:打开一个文件夹,选择*.bmp的图片,能显示并能放大缩小(急急急)
- 如何知道客户端有没有去RECEIVE
- 状态栏的字体和图标都不见?
- 请教:如何通过代理服务器进行HTTP下载?立即结帐,谢谢!
- 急急急! ???我这个程序中怎么老是 this: (value=)0x00000000 (debug)
- 画图
- 初学者关于this指针的两个疑问?谢谢
- 如何实现程序安装后自动更名并改变目录?如何实现自卸载?用什麽函数提取当前计算机的时间?
- What's New in MFC?——对MFC失去信心的人的强心剂,不过你得英语好 :)
- VS2017升级到15.6.1之后 不能自动生成控件变量
- 学习mfc深入浅出第6章中遇到的几个问题
- 如何获得某个月的最后一天是几号?
则str的内容是unicode的“Test”(每个字母占两个字节),否则就是ansi的“Test”(每个字母占一个字节).
A Sample Generic-Text Program
Microsoft Specific —>The following program, GENTEXT.C, provides a more detailed illustration of the use of generic-text mappings defined in TCHAR.H:/*
* GENTEXT.C: use of generic-text mappings defined in TCHAR.H
* Generic-Text-Mapping example program
*/#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <direct.h>
#include <errno.h>
#include <tchar.h>int __cdecl _tmain(int argc, _TCHAR **argv, _TCHAR **envp)
{
_TCHAR buff[_MAX_PATH];
_TCHAR *str = _T("Astring");
char *amsg = "Reversed";
wchar_t *wmsg = L"Is";#ifdef _UNICODE
printf("Unicode version\n");
#else /* _UNICODE */
#ifdef _MBCS
printf("MBCS version\n");
#else
printf("SBCS version\n");
#endif
#endif /* _UNICODE */ if (_tgetcwd(buff, _MAX_PATH) == NULL)
printf("Can't Get Current Directory - errno=%d\n", errno);
else
_tprintf(_T("Current Directory is '%s'\n"), buff);
_tprintf(_T("'%s' %hs %ls:\n"), str, amsg, wmsg);
_tprintf(_T("'%s'\n"), _tcsrev(str));
return 0;
}If _MBCS has been defined, GENTEXT.C maps to the following MBCS program:/*
* MBCSGTXT.C: use of generic-text mappings defined in TCHAR.H
* Generic-Text-Mapping example program
* MBCS version of GENTEXT.C
*/#include <stdlib.h>
#include <direct.h>int __cdecl main(int argc, char **argv, char **envp)
{
char buff[_MAX_PATH];
char *str = "Astring";
char *amsg = "Reversed";
wchar_t *wmsg = L"Is"; printf("MBCS version\n"); if (_getcwd(buff, _MAX_PATH) == NULL) {
printf("Can't Get Current Directory - errno=%d\n", errno);
}
else {
printf("Current Directory is '%s'\n", buff);
} printf("'%s' %hs %ls:\n", str, amsg, wmsg);
printf("'%s'\n", _mbsrev(str));
return 0;
}If _UNICODE has been defined, GENTEXT.C maps to the following Unicode version of the program. For more information about using wmain in Unicode programs as a replacement for main, see Using wmain in C Language Reference./*
* UNICGTXT.C: use of generic-text mappings defined in TCHAR.H
* Generic-Text-Mapping example program
* Unicode version of GENTEXT.C
*/#include <stdlib.h>
#include <direct.h>int __cdecl wmain(int argc, wchar_t **argv, wchar_t **envp)
{
wchar_t buff[_MAX_PATH];
wchar_t *str = L"Astring";
char *amsg = "Reversed";
wchar_t *wmsg = L"Is"; printf("Unicode version\n"); if (_wgetcwd(buff, _MAX_PATH) == NULL) {
printf("Can't Get Current Directory - errno=%d\n", errno);
}
else {
wprintf(L"Current Directory is '%s'\n", buff);
} wprintf(L"'%s' %hs %ls:\n", str, amsg, wmsg);
wprintf(L"'%s'\n", wcsrev(str));
return 0;
}If neither _MBCS nor _UNICODE has been defined, GENTEXT.C maps to single-byte ASCII code, as follows:/*
* SBCSGTXT.C: use of generic-text mappings defined in TCHAR.H
* Generic-Text-Mapping example program
* Single-byte (SBCS) Ascii version of GENTEXT.C
*/#include <stdlib.h>
#include <direct.h>int __cdecl main(int argc, char **argv, char **envp)
{
char buff[_MAX_PATH];
char *str = "Astring";
char *amsg = "Reversed";
wchar_t *wmsg = L"Is"; printf("SBCS version\n"); if (_getcwd(buff, _MAX_PATH) == NULL) {
printf("Can't Get Current Directory - errno=%d\n", errno);
}
else {
printf("Current Directory is '%s'\n", buff);
} printf("'%s' %hs %ls:\n", str, amsg, wmsg);
printf("'%s'\n", strrev(str));
return 0;
}See Also Generic-text mappings, Data type mappings, Constants and global variable mappings, Routine mappings, Using generic-text mappingsEND Microsoft Specific