CString szFindPath="adkj\\adgagd\\adgfha\\;
int nSlash = szFindPath.ReverseFind('\\'); if( nSlash == szFindPath.GetLength()-1)
{
szFindPath = szFindPath.Left(nSlash);
}
把上面代码改成不用MFC的cstring类的,大虾告诉该如何写
int nSlash = szFindPath.ReverseFind('\\'); if( nSlash == szFindPath.GetLength()-1)
{
szFindPath = szFindPath.Left(nSlash);
}
把上面代码改成不用MFC的cstring类的,大虾告诉该如何写
int nLength = strlen(szFindPath);
if(szFindPath[nLength-1] == '\\')
{
szFindPath[nLength-1] = '\0';
}
int nLength = lstrlen(szFindPath);
if(szFindPath[nLength-1] == _T('\\'))
{
szFindPath[nLength-1] = _T('\0');
}这段代码,在UNICODE 下也可以工作的
TCHAR szNew[MAX_PATH];
TCHAR ch = '\\';LPTSTR lpszText = _tcsrchr(szText, ch);
int nPos = (int)(lpszText - szText);memset(szNew, 0, sizeof(szNew)/sizeof(TCHAR));
_tcsncpy(szNew, szText, nPos);
szNew[nPos] = '\0';