将"C:\Hello.txt"中的"\"转换为"/"
将"C:\Hello.txt"中的""转换为"/",小程序。。。
[解决办法]
string str("C:\\Hello.txt");
cout << str.c_str() << endl;
str.replace(str.find("\"),1 ,"/");
cout << str.c_str() << endl;
// 将"C:\Hello.txt"中的""转换为"/"
#include <stdio.h>
int main()
{
char cContent[] = "C:\\Hello.txt" ;
int iLen = strlen(cContent);
for( int i=0; i<iLen; i++ )
{
if( cContent[i] == '\\' )
{
cContent[i] = '\/' ;
break;
}
}
}