Thread: Sentinel issue

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    147

    Sentinel issue

    i have often seen statements written like this :

    while(1){} for example...

    if the sentinel in the while statement is not a va riable, how is the loop going to end? how are we gonna end the loop?
    Only by the cross are you saved...

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    88
    while(1) will keep on going forever just like
    for( ; ; )

    you can break; out of the loop

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164

    Re: Sentinel issue

    Originally posted by fkheng
    i have often seen statements written like this :

    while(1){} for example...

    if the sentinel in the while statement is not a va riable, how is the loop going to end? how are we gonna end the loop?
    It doesn't. What you have is a infinite loop.

    Inside the block a break; is executed to break out of the loop.

    This type of while can be used when there is no clear sentinel to exit the loop.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. float calculation issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-26-2008, 04:56 AM
  2. type safe issue
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 02-12-2008, 09:32 PM
  3. Problem with sentinel values
    By Golfduffer in forum C Programming
    Replies: 3
    Last Post: 08-30-2007, 01:19 AM
  4. Sentinel while loop and errors.
    By lollypop in forum C Programming
    Replies: 12
    Last Post: 10-19-2003, 12:40 PM
  5. my first issue of GDM
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-12-2002, 04:02 PM