Sentinel while loop for C++

A “sentinel” in this context is a special value used to indicate the end of a sequence. The most common sentinel is \0 at the end of strings. A “sentinel while loop” would typically have the form:

while (Get(input) != Sentinel) {
  Process(input);
}

Leave a Comment