do – while

do - while 迴圈與 while 迴圈相似,其最大的差別在於 do - while 迴圈會先執行迴圈中程式碼再判斷條件示成立與否。


  do
  {
     // 迴圈區塊
  } while (測試條件);

範例

do
{
  delay(50);          // 等待感測器變成穩定狀態
  x = readSensors();  // 讀取感測器

} while (x < 100);

語法參考主頁面

本頁由熱血青年 LBU 譯自英文版。

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.