Sentinel value
From Wikipedia, the free encyclopedia
In computer programming, a sentinel value (also referred to as a flag value, rogue value, or signal value) is a special value that is used to terminate a loop that processes structured (especially sequential) data. The value should be selected in such a way that it will not be confused with legal data values.
Below are some examples of common sentinel values and their uses:
- Null character for indicating the end of a null-terminated string.
- Null pointer for indicating the end of a linked list.
- The empty list, (), in Lisp and its variants.
Sentinel values are often used when searching for something.[1]
[edit] See also
[edit] Notes
- ^ McConnell, Steve. "Code Complete" Edition 2 Pg. 621 ISBN - 0-7356-1967-0