while loop

Hi, I am a really beginner, I need help with this loop, I know it is an infinite loop but what else is wrong with it?

int x=0;
while (x)
{
++x;
cout<<x<< endl;
)
The last parenthesis should be } instead of ).
oops! I am sorry, I typed it wrong. Do you see any other problem? Something obvious?
When I tried to run the code in express, it doesn't run, it says to press any key to continue. So it means that is not an infinite loop...I don't know..
Last edited on
Well, x == 0 at the start so...

x=0, not x==0; it is not the same...I don't understand, so the first problem with this loop is that it doesn't cout ( is that the right expression?)

Thank you so much!
while (x)
is the same as
while (x != false)

x is 0 in the start so it never executes the loop code
Great! Thank you very much!!
Topic archived. No new replies allowed.