It was thus said that the Great Dave Dunfield once stated:
Given that the original example assumes n > 0 (the test is skipped on
first entry to the loop), you can accomplish this function with neither
an extra conditional, superfluous assignment, extra variables or use
of 'goto'
void print_arg(int *aryp, unsigned n)
{
int i;
for(i=0; ;) {
printf("%u", aryp[i]);
if(++i >= n)
break;
fputs(", ", stdout); }
putc('\n', stdout);
}
Hmmm ...
void print_arg(int *aryp,size_t n)
{
printf("%u",*aryp++);
while(--n)
{
printf(",%u",*aryp++);
}
putchar('\n');
}
-spc (avoids additional variables, no GOTOs, and one conditional ... )