Thread: Sentinel Loop?

  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,708
    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++] = //...
    }
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

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, 02:13 AM
  3. Replies: 8
    Last Post: 12-01-2008, 10:09 AM
  4. syntax question
    By cyph1e in forum C Programming
    Replies: 19
    Last Post: 03-31-2006, 12:59 AM
  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