#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string naam;
cout<<"Geef je naam in: ";
cin>>naam;
int letter;
for (; letter != string::npos;);
{
letter = naam.find("a");
naam.replace(letter, 1, "e");
}
cout<<naam;
system("pause");
}
EDIT: I'm not familiar with how string::npos (and replace) works. If you don't have long texts, I'd just use the loop. I think replace most likely does similar thing anyway.
Secondly, you're for loop contains no initialization, and does no inc/decrementing. So would it not make sense to use a while loop that only uses a condiotion?
Thirdly, you're not chaning the starting position of the where you start the search in your string so if there is more than one 'a' you won't find them; you'll just keep finding thrat first 'a'.
Lastly, you have a semi-colon on line 15 that actually makes it look like your program has frozen, but it has actualyl entered an infinite loop.