Replace '\' with '/' in c++

Hi,

How can i replace the all the occurrence of '\' character with '/' in a string.

if i give like,

url.replace(url.begin() , url.end() , '\' , '/' );

its shows error.

error C2001: newline in constant
error C2146: syntax error : missing ')' before identifier 'cout'

Thanks,
Last edited on
You can't write '\' - the backslash indicates an escape sequence, not the backslash character. You need to double it up, like this:

url.replace(url.begin() , url.end() , '\\' , '/' );
Topic archived. No new replies allowed.