Is while (1); a good way to keep a program up?

At the end of my code, I often put this to keep the program from closing:

 
while (1);


I use Microsoft VS and I prefer to close the program by clicking the red x in the corner rather than pressing enter (I associate enter with entering a value, rather than closing a program).

Are there any disadvantages or advantages to this over cin.get and cin.ignore?
For dinky console programs that you're just making for yourself it really doesn't matter.

Don't listen to me. =P
Last edited on
A disadvantage would be that it causes your processor to waste unnecessary heat/energy instead of just sleeping or waiting for input.
> Are there any disadvantages or advantages to this over cin.get and cin.ignore?

>> A disadvantage would be that it causes your processor to waste unnecessary heat/energy

And the performance of other programs running on the machine could be negatively impacted.

You don't want to degrade your n cores to n-1 cores, do you? It really does matter; just don't do it.
Topic archived. No new replies allowed.