MFC CString 字符串类函数
来源:互联网 发布:网络语土杀什么意思 编辑:程序博客网 时间:2024/04/28 07:37
重点说明,对应使用了GetBuffer函数的CString必须使用ReleaseBuff否则无法得到字符串的长度信息等。
例程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)- MFC CString 字符串类函数
- MFC 字符串类CString 源代码
- MFC中CString类字符串用法小结
- 在MFC中分割字符串,主要是利用CString函数
- MFC CString类成员函数实现原理
- MFC的字符串CString处理
- MFC的字符串CString处理
- 【框架-MFC】字符串CString:操作
- MFC的字符串CString处理
- CString 字符串切割函数
- MFC字符串操作(一)MFC CString 成员函数用法大全
- 转载:C++字符串完全指南(2) - MFC类-CString
- MFC CString 的一些函数
- MFC CString 函数用法大全
- MFC CString 函数用法大全
- C++/MFC-CString类
- MFC CString类
- MFC CString类使用方法
- 畅想微信的未来
- 程序退出
- gcc和g++的区别
- 频率域中的图像滤波
- C++编程见闻
- MFC CString 字符串类函数
- Ubuntu更新命令
- iOS开发之Objective-C与JavaScript的交互-UIWebView-stringByEvaluatingJavaScriptFromString
- hibernate映射文件set key one-to-many
- [Bug]ArcSDE10.1执行ST_Geometry大数据量的大范围查询范围结果为0
- 同态滤波器
- pro*c编译环境
- JQuery元素获取
- tableView 的cell自适应高度