While loop confusion


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 ;
return 0;
= is not the same as ==
Ah, I forgot that, I need to go learn operators again.

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')
Topic archived. No new replies allowed.