输入的字符串中如果有 “ 就变成 ” “ 输出怎么编程_(:з」∠)_
求问大神这个怎么编_(:з」∠)_
输入一个字符串,如果字符串里有",就在整个字符串外面加上"",并且将"变成""输出。= =
举个栗子:
如果输入字符串123absd"fds
就要输出 "123absd""fds"
求助啊,头发都掉光了QAQ 编程
[解决办法]
VS 2008调试通过
#include "stdafx.h"
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char str[20];
gets(str);
string str1(str);
int pos=-1;
if ((pos=str1.find("\""))!=-1)
{
str1.append("\"");
str1.insert(pos,"\"");
str1.insert(0,"\"");
}
std::cout<<str1<<std::endl;
system("pause");
return 0;
}