I got a code with an error: invalid conversion from 'const char*' to 'char'
std::string zipZap(const std::string& str){
for (unsigned i = 0; i < str.length(); i++){
if (str[i] == 'z'){
if (str[i+2] == 'p'){
str[i+1] = "";
}
}
}
return str;
}
const string cant be modified. If you want to modify the string remove const from it.
And also you are assigning string to char index of string string[i+1] = ""
Instead it should be string[i+1] = ' ' or string[i+1] = '\0'
const std::string& string
string is const, you cannot modify it like string[i+1] = "";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With