Liste des Groupes | Revenir à cl c |
In article <vtrvc6$mjoi$1@dont-email.me>,
Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
...for (i=0; i<10; i++) { code that might or might not break }>
if (i == 10) puts("It ended normally");
It's also a handy idiom for a compact list search loop
where the terminating condition is either end of the list, or
a matched entry.
If the cursor isn't the end-of-list marker, then it references
the matched entry;
Indeed. This is the common case - where you are looking for something, and
if you find it, you break out of the loop (one way or another). If you
don't find it, then the loop terminates "normally" - and you need to catch
that case.
for (n = NUM_ENTRIES; (n >= 0) && (node[n] != key); --n) continue;
if (n != -1) printf("Found key at entry %d\n",n);
Bart won't like the way you've abused C's "for" statement syntax
to your own devious ends...
(But I like it)
Les messages affichés proviennent d'usenet.