想在一个字符串中取一个子串,如:
CString s="123456";
如何取出“45”子串。
CString s="123456";
如何取出“45”子串。
解决方案 »
- 很开心-==- 正式离职了,准备休假[三亚,美女,沙滩]
- 求一个socket服务器端给客户端发信息的例子
- 一个多文档获取菜单的问题
- 续贴:求李桂成版《计算方法》课本配套算法程序的VC++图形界面程序
- 很弱的问题:为什么在.h里不能给变量赋初值
- 如何创建可以由VB调用的DLL
- 有人做过通过串口利用AT指令作手机短信开发吗?
- 文件操作高手请进
- VC 的webbrowser控件调用JS函数传递参数
- 怎样把VC程序简体界面改成繁体界面?
- 为什么使用了Calendar Control 8.0控件的程序没有办法运行?
- 我的activex要装载一个DLL,在VC里面怎么把这个ActiveX和DLL一起发布?就是让IE同时下载这两个
LPCTSTR pbuff=(LPCTSTR)s;
if (pos != -1)
{
CString szRet(&pbuff[pos], szSub.GetLength());
return szRet;
}
return "";
throw( CMemoryException );CString Mid( int nFirst, int nCount ) const;
throw( CMemoryException );Return ValueA CString object that contains a copy of the specified range of characters. Note that the returned CString object may be empty. ParametersnFirstThe zero-based index of the first character in this CString object that is to be included in the extracted substring.nCountThe number of characters to extract from this CString object. If this parameter is not supplied, then the remainder of the string is extracted.ResExtracts a substring of length nCount characters from this CString object, starting at position nFirst (zero-based). The function returns a copy of the extracted substring. Mid is similar to the Basic MID$ function (except that indexes are zero-based).For multibyte character sets (MBCS), nCount refers to each 8-bit character; that is, a lead and trail byte in one multibyte character are counted as two characters.ExampleThe following example demonstrates the use of CString::Mid.// example for CString::Mid
CString s( _T("abcdef") );
ASSERT( s.Mid( 2, 3 ) == _T("cde") );出处
msdn:// .../vs98/reference/mfc/mfc classes