VC中常用的字符类型及相应的字符串处理函数
2014-10-08 13:48
507 查看
Ansi(窄) | char | char* | const char* |
CHAR | PCHAR、PSTR、LPSTR | LPCWSTR | |
Unicode(宽) | wchar_t | wchar_t* | const wchar_t* |
WCHAR | PWCHAR、PWSTR、LPWSTR | LPCWSTR | |
T(通用) | TCHAR | TCHAR*、PTCHAR、PTSTR、LPTSTR | LPCTSTR |
另:建议使用通用类型,能够根据定义的宏,选择相应的类型。
字符串 | Ansi | Unicode | 通用 |
长度 | strlen(char *str); | wcslen(wchar_t *str); | _tcslen(TCHAR *str); |
转换 | int atoi(const char *str); | int _wtoi(const wchar_t *str); | _tstoi(const TCHAR *str); |
拷贝 | strcpy(char *strDest, const char *strSrc); | wcscpy(wchar_t *strDest, const wchar_t *strSrc); | _tcscpy(TCHAR *strDest, const TCHAR *strSrc); |
● Ansi:strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource);
● Unicode:wcscpy_s(wchar_t *strDestination, size_t numberOfElements, const wchar_t *strSource);
● 通用函数:_tcscpy_s(TCHAR *strDestination, size_t numberOfElements, const TCHAR *strSource);
numberOfElements
Size of the destination string buffer. 目的缓冲区的大小,以字节为单位!
相关文章推荐
- VC中char,wchar_t,TCHAR及相应字符串处理函数辨析(附常用数据类型转换)
- 字符 和 字符串 常用处理函数
- 【C语言】10-字符和字符串常用处理函数
- 【C语言】10-字符和字符串常用处理函数
- C中常用的字符、字符串处理函数
- 【C语言】10-字符和字符串常用处理函数
- 【C语言】10-字符和字符串常用处理函数
- C语言——字符和字符串常用处理函数
- 字符数组的定义、初始化及引用以及一些常用的字符串处理函数
- C\C++常用字符串\字符数组处理函数汇总
- 【C语言】10-字符和字符串常用处理函数
- 16字符和字符串常用处理函数
- 【C语言】10-字符和字符串常用处理函数
- 学习笔记之10-字符和字符串常用处理函数
- c++ 字符串常用处理函数
- JavaScript常用字符串处理函数
- vc 字符串的处理函数
- Delphi中常用字符串处理函数