Classical check for a zero in an array: int a[10]; int has_zero(void) { int i = 0; while (a[i] && i < 10) i++; return i < 10; }
@ch3root I would not call that "classical" but hideous and anti-idiomatic. Classical: for (i=0; i<10; i++) if (!a[i]) return 1; return 0;
-
-
@RichFelker There is a school of thought that a function should have only one exit point. "return" from inside a loop? horror! -
@RichFelker Even break, mm..., breaks natural flow of the program.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.