Need some help!

change all occurrences of 'e' to '3', of 'i' to '1', and of 'x' to '*'
Example: heel becomes h33l.

I've tried multiple things already and I'm not having any luck.
Any hints or tips?
could you show us what you did/tried???
if(1==ex) {
for (int i = 0; i < word.size(); ++i)
if(word.at(i) == 'e') {
word.at(i) == '3';

cout << "Your word is transformed: " << word.at(i);
cout << endl;
}
}
Are you using string or char?
he's using string, hence the calls to size() and at().

like this maybe:

1
2
3
4
5
6
7
8
9
10
	std::string testString("Heel");

	for(int i=0;i<testString.size();i++)
	{
		if(testString.at(i) == 'e')
		{
			testString.replace(i,1,"3");

		}
	}
Last edited on
Okay thank you,

I was able to figure it out, but thanks for the extra help!
Really thankful for your efforts!
Topic archived. No new replies allowed.