#include <iostream>
using namespace std;
char* str1_str2(char ch[])
{
char *tmp = (char *)malloc(sizeof(1024)); //记得释放内存
char *p = ch;
int i=0;
while(*p!=NULL)
{
tmp[i] = *p;
i++;
p++;
if(*(p-1) == '\\') //注解:反斜杠\字符用'\\'表示
{
tmp[i] = '\\';
i++;
}
}
tmp[i] = '\0';
return tmp;
}
int main()
{
char from[] = "abcd\\efg\\cdmie\\xwio";//双引号“”中的\是转义字符的意思
cout<<"输入字符串="<<from<<endl;
char *to = str1_str2(from);
cout<<"输出字符串="<<to<<endl;
}
C++中\变成\\
最新推荐文章于 2023-07-14 21:45:00 发布