C++中\变成\\
#include <iostream>
using namespace std;
char* str1_str2(char ch[])
{char *tmp = (char *)malloc(sizeof(1024)); //記得釋放內(nèi)存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";//雙引號(hào)“”中的\是轉(zhuǎn)義字符的意思cout<<"輸入字符串="<<from<<endl;char *to = str1_str2(from);cout<<"輸出字符串="<<to<<endl;
}
總結(jié)
- 上一篇: 鸡啄米:模态、非模态对话框
- 下一篇: MFC显示JPG、JIF图片