By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,101 Members | 1,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,101 IT Pros & Developers. It's quick & easy.

control statements in c Infinite looping controls

P: 2
Why you are using infinite loop in while and do while inside 1 only? and why can't I put any value?
Jul 27 '17 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 9,197
Infinite loops are common in menu based applications where you want to return to the menu until the exit choice is selected.

I have the entire program inside an infinite loop:

Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.      while (1)
  4.      {
  5.        Program();
  6.      }
  7. {
If Program() returns, it is just restarted.
Jul 27 '17 #2

Expert 100+
P: 2,398
I think your question is why do people use "while(1)" instead of "why(42)"?
The convention is to use "1" even though any nonzero constant would do the same thing.
Jul 28 '17 #3

Post your reply

Sign in to post your reply or Sign up for a free account.