CString截取字符串全攻略
来源:互联网 发布:旋风冲锋龙卷风知乎 编辑:程序博客网 时间:2024/05/01 11:46
CString截取字符串全攻略
源地址 http://blog.163.com/seraph_leo/blog/static/1689297102010786206361/?fromdm&fromSearch&isFromSearchEngine=yes
例程1:(csdn)
文件xxxx.dll去掉后面的.dll
char str[] = "xxxx.dll"
char*p;
p=strrchr(str, '.');
*p = 0;
CString str="xxxx.dll";
int n = str.ReverseFind('.')
str = str.Left(str.GetLength()-n-1);
CString m_char,m_disp;
m_disp="jadfueiuajdf?";
m_char="?";
if (!m_char.IsEmpty())
{
int index = m_disp.Find(m_char);
m_disp = m_disp.Right(m_disp.GetLength()-index-1);
}
CString temp=the.m_bb;
CString reslut=temp.Left(temp.Find("?")-1);
CString m_StrReceiveModem;
int nPos = m_StrReceiveModem.Find('$');
if(nPos >= 0)
{
CString sSubStr = m_StrReceiveModem.Mid(nPos);//
}
CString m_StrReceiveModem;
int nPos = m_StrReceiveModem.Find('$');
if(nPos >= 0)
{
CString sSubStr = m_StrReceiveModem.Right(StrReceiveModem.GetLength()-nPos);
}
}
//截取“$”到“#”的字符串
int first,last;
first= m_StrReceiveModem.Find("$");
last= m_StrReceiveModem.Find("#");
CString sSubStr = m_StrReceiveModem.Mid(first,last);
例程4: (fox)
CString::Find()函数
2010-11-17 12:05:04|
注:CString::Find函数,如果给定的参数是一个字符串,那么它必须与此字符串中的某一个子字符串完全匹配才能返回相匹配的子字符串第一个字符的索引。
CString::Find
作用
在一个较大的字符串中查找字符或子字符串 int Find( TCHAR ch ) const; int Find( LPCTSTR lpszSub ) const; int Find( TCHAR ch, int nStart ) const; int Find( LPCTSTR lpszSub, int nStart ) const;返回值
返回此CString对象中与需要的子字符串或字符匹配的第一个字符的从零开始的索引;如果没有找到子字符串或字符则返回-1。参数
ch 要搜索的单个字符。 lpszSub 要搜索的子字符串。 nStart 字符串中开始搜索的字符的索引,如果是0,则是从头开始搜索。如果nStart不是0,则位于nStart处的字符不包括在搜索之内。 pstr 指向要搜索的字符串的指针说明
此成员函数用来在此字符串中搜索子字符串的第一个匹配的字符。函数的重载可以接收单个字符(类似于运行时函数strchr)和字符串(类似于strstr)。//下面演示第一个例子
// CString::Find( TCHAR ch ) CString s( "abcdef" ); int n = s.Find( 'c' ); // 结果 n = 2 int f = s.Find( "de" ) ; // 结果 f = 3 ASSERT( n == 2 ); ASSERT( f == 3 ); // 下面演示第二个例子 // CString::Find(TCHAR ch,int nStart) CString str("The stars are aligned"); int n = str.Find('e',5); //结果 n = 12 ASSERT(n == 12)- CString 截取字符串全攻略
- CString截取字符串全攻略
- CString截取字符串全攻略
- CString截取字符串全攻略
- CString截取字符串全攻略
- CString截取字符串全攻略
- CString截取字符串全攻略
- CString 截取字符串
- cstring 截取字符串
- cstring 截取字符串
- CString字符串截取
- CString 字符串截取
- CString字符串截取
- CString截取字符串
- CString字符串查找和截取
- CString字符串查找和截取
- 字符串全攻略
- 字符串全攻略
- UVA 11292 - The Dragon of Loowater (water)
- nginx 四/七层负载均衡设备
- 使用DLL文件生成LIB文件实现动态链接
- OBJECT TO HEX FILE CONVERTER OH51 V2.6 COPYRIGHT KEIL ELEKTRONIK GmbH 1991 - 2001问题的解决
- css练手-android机器人
- CString截取字符串全攻略
- Mahout架构初探及KMeans算法分布式实现的研究
- Windows系统时间(FILETIME和SYSTEMTIME)
- 一份比较详细的DOS命令说明
- 3.easyui+ztree案例:使用easyui布局
- 适用于Java程序员的通信顺序进程
- iframe去边框,无边框,使用大全
- Java线程详解
- linux 内核参数调整优化网络