On 5/16/05, Jim Battle <frustum at pacbell.net> wrote:
I'd do this, and didn't even know that jumping
into the middle of the
FOR loop was legal. Even knowing it is legal, I prefer my way (of course):
void print_ary (int *aryp, int n)
{
int i;
for (i=0; i<n; aryp++, i++)
{
if (i>0)
printf (", ");
printf ("%u", *aryp);
}
printf ("\n");
}
Jumping into a for loop is legal (in C anyway, problematic in C++ if
you're using automatic object variables w/ constructor that needs
executing on entry to the block). You miss the initializer altogether,
the test the first time through, but you'll hit the first increment at
the bottom of the loop.
I could do it your way, but it has an unnecessary conditional. Not a
big sacrifice, I admit. Not worth getting hit with an eraser anyway.
-- John.