replacing a char with another char in a string

how would i go about replacing a character with another character.

an example would be replace all 'a' with 'b'.

imput: abc
output: bbc

i need to detect all 'a' in the string and replace with 'b' no matter the length or size of the string. string is only one word with no spaces.
Last edited on
You can think of a string as "an array of characters". So just check each character of the string for whether it's the one you want to replace, and then... just do it.
Don't worry i finally figured it out.

replace( str.begin(), str.end(), 'a', 'b');
Topic archived. No new replies allowed.