All your while loops are wrong. while tests the condition before entering the loop, but you want to execute the loop body once before checking whether to exit or not. Replace
while (...cond...) { ...body... }
with
do { ...body... } while (...cond...);
In reply to Re^3: returning to a loop later on
by ikegami
in thread returning to a loop later on
by Yoda_Oz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |