常用字符串函数
来源:互联网 发布:超好看杂志 知乎 编辑:程序博客网 时间:2024/05/16 10:16
常用字符串函数
1. 字符串比较函数
//比较两个字符串是否相同int StrCmp(LPCTSTR lpStr1,LPCTSTR lpStr2);int StrCmpN(LPCTSTR lpStr1,LPCTSTR lpStr2,int nChar);
2. 计算字符串长度
HRESULT StringCchLength( LPCTSTR psz,size_t cchMax,size_t *pcch); //replacement for strlen
3. 字符串赋值函数
HRESULT StringCchCopy(LPTSTR pszDest,size_t cchDest,LPCTSTR pszSrc); //replacement for strcpy
HRESULT StringCchCopyN(LPTSTR pszDest,size_t cchDest,LPCTSTR pszSrc,size_t cchSrc); //replacement for strncpy
LPTSTR StrCpy(LPTSTR psz1,LPCTSTR psz2); //存在安全问题
LPTSTR StrCpyN(LPTSTR psz1,LPCTSTR psz2,int cchMax); //存在安全问题
char *strcpy( char *strDestination, const char *strSource );
wchar_t *wcscpy( wchar_t *strDestination, const wchar_t *strSource );
wchar_t *wcscpy( wchar_t *strDestination, const wchar_t *strSource );
char *strncpy( char *strDest, const char *strSource, size_t count );
wchar_t *wcsncpy( wchar_t*strDest, const wchar_t *strSource, size_t count );
wchar_t *wcsncpy( wchar_t*strDest, const wchar_t *strSource, size_t count );
4. 字符串连接函数
HRESULT StringCchCat( LPTSTR pszDest,size_t cchDest,LPCTSTR pszSrc); //replacement for strcat
HRESULT StringCchCatN( LPTSTR pszDest,size_t cchDest,LPCTSTR pszSrc,size_t cchMaxAppend); //replacement for strncat
LPTSTR StrCat( LPTSTR psz1,LPCTSTR psz2); //存在安全问题
LPTSTR StrNCat( LPTSTR pszFront,LPCTSTR pszBack,int cchMax); //存在安全问题
char *strcat( char *strDestination, const char *strSource );
wchar_t *wcscat( wchar_t *strDestination, const wchar_t *strSource );
wchar_t *wcscat( wchar_t *strDestination, const wchar_t *strSource );
char *strncat( char *strDest, const char *strSource, size_t count );
wchar_t *wcsncat( wchar_t *strDest, const wchar_t *strSource, size_t count );
wchar_t *wcsncat( wchar_t *strDest, const wchar_t *strSource, size_t count );
5. 字符查找函数
//查找字符串中指定字符第一次出现的位置
LPTSTR StrChr( LPCTSTR lpStart,TCHAR wMatch); //区分大小写
LPTSTR StrChrI( LPCTSTR lpStart,TCHAR wMatch); //不区分大小写
//查找字符串中指定字符最后一次出现的位置
LPTSTR StrRChr( LPCTSTR lpStart,LPCTSTR lpEnd,TCHAR wMatch); //区分大小写
LPTSTR StrRChrI( LPCTSTR lpStart,LPCTSTR lpEnd,TCHAR wMatch); //不区分大小写
*注 StrRChr()函数可以通过StrChr()函数和while循环来实现。
补充:
查找字符串:
_tcsstr(........)
字符串转化为double型数字
_tcstod( const char *nptr, char **endptr )
字符串转化为double型整数(只取整数部分,不取小数)Convert strings to a long-integer value.
_tcstoul ( const char *nptr, char **endptr, int base )
_tcstol ( const char *nptr, char **endptr, int base )
取子字符串
Extracts a substring of length nCount characters from this CStringT object, starting at position iFirst (zero-based).
CStringT Mid( int iFirst, int nCount) const;CStringT Mid( int iFirst) const; example: //typedef CStringT< TCHAR, StrTraitATL< TCHAR > > CAtlString;CAtlString s( _T("abcdef") );_ASSERT( s.Mid( 2, 3 ) == _T("cde") ); |
- 字符串__常用字符串函数
- 字符串以及字符串常用函数
- SQL常用字符串函数
- SQL常用字符串函数
- 常用SQL字符串函数
- 常用SQL字符串函数
- SQL常用字符串函数
- SQL常用字符串函数
- VB常用字符串函数
- 字符串操作常用函数
- 常用字符串函数
- SQL常用字符串函数
- 常用SQL字符串函数
- SQL常用字符串函数
- 常用:javascript字符串函数
- 常用SQL字符串函数
- SQL常用字符串函数
- SQL常用字符串函数
- 一些常用的网络检测工具
- Vista user account cannot logon
- 揭密鬼页 浅析浏览器跨域安全问题
- 如何学习C#——For My Class
- 开发设计模式 -- Asp.net中实现观察者模式
- 常用字符串函数
- Firstly use ubutun
- 换工作记(一)
- OpenDwg开发问题集锦
- win32局域网命令行方式聊天程序C实现
- ntldr带给我的烦恼
- 重叠I/O模型
- View DNS in Linux system
- access与SqlServer 之SQL语句比较