CString Find & ReverseFind[通俗易懂]

发布时间:2025-12-09 14:09:41 浏览次数:15

CString szTemp = “d:\VS project\IniPractice\debug\IniPractice.exe”;

int nIndex1 = szTemp.Find(‘\\’);

//nIndex1 = 2; 从左往右查找,并给出索引值

int nIndex2 = szTemp.ReverseFind(‘\\’);

//nIndex2 = 31;从右往左查找,并反向给出索引值

TCHAR szPath[MAX_PATH];::GetModuleFileName(NULL, szPath, MAX_PATH);CString szCurrentDirectory = (CString)szPath;::AfxMessageBox(szCurrentDirectory);int nIndex = szCurrentDirectory.Find('\\');CString szTemp;szTemp.Format("%d",nIndex);::AfxMessageBox(szTemp);szCurrentDirectory = szCurrentDirectory.Left(szCurrentDirectory.ReverseFind('\\'));::AfxMessageBox(szCurrentDirectory);
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477