CString 类中有两个成员函数:
1) .GetLength()得到字符串的长度。
2) .Left(int nCount) 从左边截取字符串,nCount是截取的字符长度。
故你要删除最后一个g;只要从左边截取该字符串的长度-1的长度。
如下:
CString str="abcdefg";
str=str.Left(str.GetLength()-1);
CString s( _T("abcdefg") );
ASSERT( s.Mid( 0, 6 ) == _T("abcdef") );
CString str="abcdefg";
str = str.Mid(0,str.GetLength()-1);