using namespace std;
int main()
{
char repeat;
do
{
string str;
cout << "What is your first and last name? " << endl;
getline(cin, str);
string findSpace = " ";
int found = str.find(findSpace) + 1;
cout << str[0] << str[found] << endl;
cout << "repeat? " << endl;
cin >> repeat;
} while (repeat == 'y');
}
I have this code that helps me get the initials of the first and last name. But when I go to repeat the code it automatically couts "What is your first and last name?" as well as "repeat?". It won't go through the steps of asking for the first and last name, giving the initials, and then asking if the user wants to repeat.
What am I doing wrong here?