一、CString——Left、Right、Find、ReverseFind
CString——Left、Right、Find、ReverseFind
CString::Left(intnCount)
——返回字符串前nCount个字符的字符串
example:
CString str(_T("Shop,车间"));
str = str.Left(4);
结果:str="Shop";
CString::Right(int nCount)
——返回字符串后nCount个字符的字符串
example:
CString str(_T("Shop,车间"));
str = str.Right(2);
结果:str="车间";
CString::Find(_T(","))
返回“,”在字符串中的索引值
example:
CString str(_T("Shop,车间"));
int idex = str.Find(_T(","));
此时:idex=4;
宗:要想获得“,”右侧内容
str = str.Right(str.GetLength()-1-str.Find(_T(",")));
其中:
str.GetLength()=7;
-1排除“,”
-str.Find(_T(","))排除“,”前的所有字
CString::ReverseFind
int ReverseFind( TCHAR ch ) const;
返回值:
返回此CString对象中与要求

本文介绍了MFC中CString的Left、Right、Find、ReverseFind方法的使用,以及如何进行char和wstring之间的转换。同时讲解了四种获取应用程序所在目录的方法,包括GetCurrentDirectory、SetCurrentDirectory、GetModuleFileName和_splitpath等函数的应用。
最低0.47元/天 解锁文章
2388

被折叠的 条评论
为什么被折叠?



