Liste des Groupes | Revenir à cl c |
On Fri, 18 Apr 2025 13:58:08 +0000, Kenny McCormack wrote:That's fine. It's been far longer that I've given up caring what people think of my generated C code
In article <vtrvc6$mjoi$1@dont-email.me>,I've long since stopped caring what Bart does or doesn't like. :-)
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
I'll give you this one. Finally something that is impossible to achieve with a simple and far more appropriate 'while':to your own devious ends...I'll give you another devious one :-)
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
double nc;
for (nc = 0; getchar() != EOF; ++nc)
;
printf("%.0f\n",nc);
As do I. It is succinct, complies with the syntax of the C language,That's a pretty low bar. You can say the same about any of my generated, low-level C code, which is pretty much unreadable by any human.
and achieves the desired algorithmic goal.
Les messages affichés proviennent d'usenet.