关于字符串的处理总结

常见的字符串类型:

char wchar_t cstring string 

关于字符串处理的函数,具体例子: 

strcat(str1,str2);
tcslen(str) 获得字符串长度
tcsrchr(str, L'\\') 反向搜索获得最后一个TCHAR的位置
stprintf(TCHAR *buffer,const TCHAR *format [,argument] ..)获得一个格式化字符串
tcsdup 给一个指针分配源字符串大小的内存并从源字符串copy值
tcstok 按标记将字符串拆分
tcscpy 拷贝字符串.
字符串连接函数strcat(),将strSource连接到strDestination
下面是MSDN的声明:
 1 char *strcat(
 2    char *strDestination,
 3    const char *strSource 
 4 );
 5 wchar_t *wcscat(
 6    wchar_t *strDestination,
 7    const wchar_t *strSource 
 8 );
 9 unsigned char *_mbscat(
10    unsigned char *strDestination,
11    const unsigned char *strSource 
12 );
13 template <size_t size>
14 char *strcat(
15    char (&strDestination)[size],
16    const char *strSource 
17 ); // C++ only
18 template <size_t size>
19 wchar_t *wcscat(
20    wchar_t (&strDestination)[size],
21    const wchar_t *strSource 
22 ); // C++ only
23 template <size_t size>
24 unsigned char *_mbscat(
25    unsigned char (&strDestination)[size],
26    const unsigned char *strSource 
27 ); // C++ only

 

 

typedef byte BYTE;
typedef unsigned short WORD;
typedef unsigned int UINT;
typedef int INT;
typedef long BOOL;
typedef long LONG;
typedef unsigned long DWORD;
typedef void *HANDLE;
typedef WORD *LPWORD;
typedef DWORD *LPDWORD;
typedef char CHAR;
typedef /* [string] */  __RPC_string CHAR *LPSTR;
typedef /* [string] */  __RPC_string const CHAR *LPCSTR;
typedef wchar_t WCHAR;
typedef WCHAR TCHAR;
typedef /* [string] */  __RPC_string WCHAR *LPWSTR;
typedef /* [string] */  __RPC_string TCHAR *LPTSTR;
typedef /* [string] */  __RPC_string const WCHAR *LPCWSTR;
typedef /* [string] */  __RPC_string const TCHAR *LPCTSTR;
typedef HANDLE *LPHANDLE;

 

举例

posted @ 2016-08-16 17:23  vsxw  阅读(303)  评论(0编辑  收藏  举报