用于C++的Sentinel while循环

yih*_*gho 12 c++ loops while-loop

任何人都可以告诉我在C++循环中什么是哨兵?请给我一个使用sentinel while循环的例子.

MSa*_*ers 23

在此上下文中的"哨兵"是用于指示序列结束的特殊值.最常见的哨兵是字符串末尾的\ 0."endinel while循环"通常具有以下形式:

while (Get(input) != Sentinel) {
  Process(input);
}
Run Code Online (Sandbox Code Playgroud)