c++ - Replacing character in the string -
i trying enter in array 2 ` backqoutes. enters single quote. please me here ?
input:
abc"cde"fgh"ijkl"
ouput:
abc``cde''fgh``ijkl''
my code:
#include <stdio.h> #include <iostream> #include <cstring> using namespace std; int main() { string mystr; long int i=0,j=0,l; while(getline (cin, mystr)) { // l=strlen(mystr); l=mystr.length(); for(i=0;i<l;i++) { if (mystr[i]=='"') { j=j+1; if(j%2==1) mystr[i]='``'; //problem here else mystr[i]='"'; } } cout << mystr; i++; } return 0; }
it c++. "``" not char 2 char. use concatenation instead like
result += "``";
Comments
Post a Comment