Can anybody tell me what actually is a "Sentinel Loop"? How is it different from others?
Thanks.
Printable View
Can anybody tell me what actually is a "Sentinel Loop"? How is it different from others?
Thanks.
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++] = //...
}