已知文件路径的格式可能为
E:\\work/\c++\test//1.cpp这样的混搭格式,编写下列函数:bool FormatFilePath(CString& strPath); //将文件路径格式化为E:\work\c++\test\1.cpp
谢谢各位慷慨解惑。谢谢了!
E:\\work/\c++\test//1.cpp这样的混搭格式,编写下列函数:bool FormatFilePath(CString& strPath); //将文件路径格式化为E:\work\c++\test\1.cpp
谢谢各位慷慨解惑。谢谢了!
我自己没写过,但我看到过 CString strinfor = GetStringFromUrl(OPENID_ADDRESS + m_strAccessToken);
int nNum;
nNum = strinfor.Find(_T("\"openid\":\""));
if (nNum > 0)
{
int nlength = strinfor.GetLength();
CString strTmp2 = strinfor.Right(nlength - nNum - 10);
int nPos = strTmp2.Find(_T("\"}"));
if(nPos >= 0)
m_strOpenId = (CStringA)strTmp2.Left(nPos);
}你可以试试看,估计有点麻烦
{
int t = 0;
while(0 != strPath.Replace(_T("/"),_T("\\"))) t ++;
while(0 != strPath.Replace(_T("\\\\"),_T("\\"))) t ++; return t > 0;
}
int Replace( TCHAR chOld, TCHAR chNew );int Replace( LPCTSTR lpszOld, LPCTSTR lpszNew );Return ValueThe number of replaced instances of the character. Zero if the string isn't changed.ParameterschOldThe character to be replaced by chNew.chNewThe character replacing chOld.lpszOldA pointer to a string containing the character to be replaced by lpszNew.lpszNewA pointer to a string containing the character replacing lpszOld.ResCall this member function to replace a character with another. The first prototype of the function replaces instances of chOld with chNew in-place in the string. The second prototype of the function replaces instances of the substring lpszOld with instances of the string lpszNew. The string may grow or shrink as a result of the replacement; that is, lpszNew and lpszOld do not have to be equal in length. Both versions perform case-sensitive matches.Example//First example, with old and new equal in length.CString strZap("C--");
int n = strZap.Replace('-', '+');
ASSERT(n == 2);
ASSERT(strZap == "C++");//Second example, old and new are of different lengths.CString strBang("Everybody likes ice hockey");
n = strBang.Replace("hockey", "golf");
ASSERT(n == 1);
n = strBang.Replace("likes", "plays");
ASSERT(n == 1);
n = strBang.Replace("ice", NULL);
ASSERT(n == 1);
ASSERT(strBang == "Everybody plays golf");// note that you now have an extra space in your
// sentence. To remove the extra space, include it
// in the string to be replaced, i.e.,"ice ".CString Overview | Class Members | Hierarchy ChartSee Also CString::Remove