Sentinel Loop?

This is a discussion on Sentinel Loop? within the C Programming forums, part of the General Programming Boards category; Can anybody tell me what actually is a "Sentinel Loop"? How is it different from others? Thanks....

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    15

    Question Sentinel Loop?

    Can anybody tell me what actually is a "Sentinel Loop"? How is it different from others?

    Thanks.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    A loop that stops when a predetermined "sentinal" value is reached. For character arrays, this is the value zero, and infact all of the string.h functions rely on this fact to function properly.

    while( array[i] != sentinal ){
    //...process data...
    }

    This is opposed to the approach of looping till a certain limit is reached:

    while( i < max ){
    array[i++] = //...
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My loop within loop won't work
    By Ayreon in forum C Programming
    Replies: 3
    Last Post: 03-18-2009, 10:44 AM
  2. Visual Studio Express / Windows SDK?
    By cyberfish in forum C++ Programming
    Replies: 23
    Last Post: 01-22-2009, 01:13 AM
  3. Replies: 8
    Last Post: 12-01-2008, 09:09 AM
  4. syntax question
    By cyph1e in forum C Programming
    Replies: 19
    Last Post: 03-30-2006, 11:59 PM
  5. How to change recursive loop to non recursive loop
    By ooosawaddee3 in forum C Programming
    Replies: 1
    Last Post: 06-24-2002, 08:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21