vc中字符串问题,急!!!!急!!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/12 13:49:28
关于路径转换的问题
C:\Documents and Settings\sono\桌面\EBook\Ebook_\ReadMe.txt
转换成C:\\Documents and Settings\\sono\\桌面\\EBook\\Ebook_
用C++实现,最好用mfc的CString,由于\再c++中是转义字符,所以问题才变得复杂!!

TCHAR sz[100];
::GetSystemDirectory(sz,100);
MessageBox(sz);
CString str = sz;
str.Replace(_T("\\"),_T("\\\\"));
MessageBox(str);

第一次提示c:\windows\system32
第二次提示c:\\windows\\system32

dim Str as String
str="C:\Documents and Settings\sono\桌面\EBook\Ebook_\ReadMe.txt "
msgbox replace(str,"\","\\")