4 ms·
do { update_thing(&foo); } while (foo != 0);
by zokier 15y ago
do {
update_thing(&foo);
} while (foo != 0);
- jws 15y agoThis works for the example as typed, but not if there is a body to the original loop.
- onemoreact 15y agoA little ugly but you can get it to work without duplicate code by: bool second_loop = false; do { if (second_loop) {...} update_thing(&foo); second_loop = true; } while (foo != 0); The real question is which is more clear when some else looks at the code. I suspect even if it's shorter and faster while (foo,bar) is less clear to most people than the above code.