Loading ...
Sorry, an error occurred while loading the content.

Re: How to code an infinite loop (was: What do you thinkabout these two coding idioms?)

Expand Messages
  • Paul Sinnett
    ... get_user_input: x = getUserChoice(); if ( x 5 ) { std::cout
    Message 1 of 1 , Feb 28, 2001
    • 0 Attachment
      >"If you can think of a non-infinite-loop way to avoid repetition,
      >communicate the intent better and still have the same behavior,
      >you'll win an even bigger prize."


      get_user_input:
      x = getUserChoice();
      if ( x < 1 || x > 5 )
      {
      std::cout << x << " was out of range. Please try again.\n";
      goto get_user_input;
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.