Error: invalid conversion from char to const char. Please help

I'm working on a project that will take in an encoded string and decode it using a variety of string manipulations. For this particular one, every character in the string needs to be subtracted by val, so for example "mt|%st|%gwt|s%ht|" should output to "how now brown cow" using val=5. The problem I'm having is in the line.replace code. I'm getting an invalid conversion from char to const char on the third parameter. Any ideas on what I'm missing? Thanks in advance.


void subtract(string & line, int val){



for(int offset=0; offset<line.size(); offset++)
{
char replace=line[offset]-val;
line.replace(offset,1,replace);
}

cout<<line<<endl;
return;
}
> I'm getting an invalid conversion from char to const char on the third parameter.
No, you are getting `invalid conversion from char to const char* (┬┐haven't heard of pointers?)

line[offset] = replace;
Sorry I'm fairly new so I've heard of them but I'm not too familiar with using them. I found an alternative way to achieve what I wanted. Thanks for the help!
Topic archived. No new replies allowed.