從左邊 1開始取得前 nCount 個字元。

CString Left( int nCount ) const;

 

從左邊第 nCount+1 個字元開始,取得後面所有的字元。

CString Mid( int nFirst ) const;

 

從左邊第 nFirst+1 個字元開始,取得後面 nCount 個字元。

CString Mid( int nFirst , int nCount ) const;

 

從右邊 1 開始取得從右向左前 nCount 個字元。

CString Right( int nCount ) const;

 

 

註:

在函數後面加 const 的意思是,如果一個類宣告了一個常量物件,這個物件只能使用後邊帶 const 這個的方法。

 

範例碼(一):

CString a,b;

a = "123456789";

b = a.Left(4);   //值為:1234

b = a.Mid(3);    //值為:456789

b = a.Mid(2, 4); //值為:3456

b = a.Right(4);  //值為:6789

 

 

Reference:http://blog.csdn.net/qingqinglanghua/article/details/4992624

arrow
arrow

    mitblog 發表在 痞客邦 留言(0) 人氣()