On 5/16/05, Dave Dunfield <dave04a at dunfield.com> wrote:
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);
}
Now that's a right answer.
-- John.