It probably didn't solve the problem because you didn't do it, or at least didn't do it properly.
Case in point:
Code:
#include <iostream>
int main()
{
std::string s1, s2;
int num;
char yn;
for(int i=0;i<3;i++)
{
std::cout << "Enter string 1: ";
getline(std::cin, s1, '\n');
std::cout << "Enter string 2: ";
getline(std::cin, s2, '\n');
std::cout << "Enter int 1: ";
std::cin >> num;
do
{
std::cout << "Enter [Y/N]: ";
std::cin >> yn;
std::cin.ignore(); /* Important */
}
while((yn != 'Y') && (yn != 'N'));
}
return 0;
}
First iteration of output without the std::cin.ignore():
Enter string 1: s1
Enter string 2: s2
Enter int 1: 1
Enter [Y/N]: Y
Enter string 1: Enter string 2: S2
First iteration of output with the std::cin.ignore():
Enter string 1: s1
Enter string 2: s2
Enter int 1: 1
Enter [Y/N]: Y
Enter string 1: S1