I can't get this incredibly simple loop to work. What's wrong with it? HELP! The While loop should stop when the user presses anything other than 'n'. But this doesn't happen. Why?
#include <iostream>
using namespace std;
char quit;
int main ()
{
quit = 'n';
while (quit = 'n')
{
cout << "Quit? ";
cin >> quit ;
system("PAUSE");
}
return 0;
}
Moschops is right.
'=' is a assignment operator whereas '==' is a relational operator.
when u write 'a=b' u actually assign the value of a as b.
But when u write 'a==b' u actually check the relation if a's value is equal to b.
so u should be using while (quit=='n')