一段简单代码~~~ 马上给分~~
函数功能: 把'\'字符转换成‘\\’字符。
bool Trans(string& str)
{
if(str.empty())
return false;
string::size_type rep ;
string::size_type cur = 0;
while(cur!=string::npos)
{
rep = str.find_first_of( "\" , cur); //这里和下一行出错
if(rep == string::npos)
return true;
str.replace(rep , rep , "\\");
cur = rep++;
}
return true;
}
projects\test\test.h(103) : error C2001: newline in constant
f:\vpn\testprojects\test\test.h(104) : error C2143: syntax error : missing ')' before 'if'
Error executing cl.exe.