第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

c++ MFC中怎樣獲取部分字符串?

c++ MFC中怎樣獲取部分字符串?

梵蒂岡之花 2019-02-06 11:07:01
c++ MFC中怎樣獲取部分字符串,定義CSring s=“adbdksf”比如獲取第二個(gè)到第四個(gè)字符
查看完整描述

3 回答

?
慕容3067478

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊

CString 有下面幾個(gè)函數(shù)
Mid Extracts the middle part of a string (like the Basic MID$ function).
Left Extracts the left part of a string (like the Basic LEFT$ function).
Right Extracts the right part of a string (like the Basic RIGHT$ function).
SpanIncluding Extracts a substring that contains only the characters in a set.
SpanExcluding Extracts a substring that contains only the characters not in a set.
點(diǎn) Mid

CString::Mid
CString Mid( int nFirst ) const;
throw( CMemoryException );

CString Mid( int nFirst, int nCount ) const;
throw( CMemoryException );

Return Value

A CString object that contains a copy of the specified range of characters. Note that the returned CString object may be empty.

Parameters

nFirst

The zero-based index of the first character in this CString object that is to be included in the extracted substring.

nCount

The number of characters to extract from this CString object. If this parameter is not supplied, then the remainder of the string is extracted.

Remarks

Extracts 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.

Example

The following example demonstrates the use of CString::Mid.

// example for CString::Mid
CString s( _T("abcdef") );
ASSERT( s.Mid( 2, 3 ) == _T("cde") );
第2到第4(序號(hào)是從0開(kāi)始的 indexes are zero-based,第2個(gè)就是1,2到4總共3個(gè)字符)

s,Mid(1,3)



查看完整回答
反對(duì) 回復(fù) 2019-03-14
?
慕虎7371278

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超4個(gè)贊

用CString的Mid函數(shù),第一個(gè)參數(shù)是從第幾個(gè)開(kāi)始,第二個(gè)參數(shù)是取多少個(gè),返回值是一個(gè)新的CString對(duì)象。
如CString str = "123456";
CString substr = str.Mid(2,2);
返回“34“

查看完整回答
反對(duì) 回復(fù) 2019-03-14
?
翻過(guò)高山走不出你

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超3個(gè)贊

cstring c;
c.assign(s,2,4);
頭文件#include<string.h>
建議看下c++模板

查看完整回答
反對(duì) 回復(fù) 2019-03-14
  • 3 回答
  • 0 關(guān)注
  • 1679 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)