Why can't I stop the loop even after I put
while ("answer" != 0);
on the answer input I press 0, but the loop still continue.
Please help.
Code:
//User input poll of "Do you like _______ ?"
//3 possible poll responds; r1, r2, r3.
#include <iostream>;
#include <string>;
using namespace std;
int main()
{ //question
string poll;
//answers
string answer;
string y;
string n;
int count1;//yes
int count2;//no
int count3;//no idea
cout << "NOTE: There are only 3 possibles answers to this poll:\n";
cout << "1.yes.\n";
cout << "2.no. \n";
cout << "3.no idea \n";
cout << "Press the answer's number and then ENTER to add poll.\n";
cout << "Example: press 1 to answer yes.\n";
cout << "To end poll, press 0.\n";
cout << "What would you like to ask? (Type below) \n\n";
getline(cin, poll);
do
{
cout << "Vote for yes? y/n \n";
cin >> answer;
if ( answer != "y" || answer != "n")
{ cout << "Invalid choice.\n"; }
}
while ( "answer" != 0);
system("pause");
return 0;
}