Liste des Groupes | Revenir à cl c |
On Wed, 20 Nov 2024 12:31:35 -0000 (UTC), Dan Purgert wrote:
>On 2024-11-16, Stefan Ram wrote:>Dan Purgert <dan@djph.net> wrote or quoted:if (n==0) { printf ("n: %u\n",n); n++;}
if (n==1) { printf ("n: %u\n",n); n++;}
if (n==2) { printf ("n: %u\n",n); n++;}
if (n==3) { printf ("n: %u\n",n); n++;}
if (n==4) { printf ("n: %u\n",n); n++;}
printf ("all if completed, n=%u\n",n);
above should be equivalent to this
>
for(;n>=0&&n<5;++n) printf ("n: %u\n",n);
printf ("all if completed, n=%u\n",n);
Well, it's a blue moon when someone nails it. Most of them fall
for my little gotcha hook, line, and sinker.
>
#include <stdio.h>
>
const char * english( int const n )
{ const char * result;
if( n == 0 )result = "zero";
if( n == 1 )result = "one";
if( n == 2 )result = "two";
if( n == 3 )result = "three";
else result = "four";
return result; }
>
void print_english( int const n )
{ printf( "%s\n", english( n )); }
>
int main( void )
{ print_english( 0 );
print_english( 1 );
print_english( 2 );
print_english( 3 );
print_english( 4 ); }
Les messages affichés proviennent d'usenet.