I trump thee collectively:
void print_arg(int *aryp, size_t n)
{
char *t="%u,";
int i=0;
for (;(i==n-1 ? t="%u" : i<n);) printf(t, *aryp + i++);
putchar('\n');
}
A little ugly (the compiler complains about the type mismatch in the unary
expression) but otherwise it works without caveats (that I know of ;)
I suspect someone might bum it down further...no more precious time to
expend on this useless pursuit ;)
I'm a little confused about the definition of "trump" when used in
this case:
- You have returned to an excess of local variables, and the
extra assignment - although you have used a (more expensive)
conditional to defer it until the last iteration.
- You have returned to TWO conditionals, although you have
creatively moved them both into the for statement.
- In the last iteration of the loop you are stuffing the address
value of the constant string "%u" into the for conditional
(granted in any reasonable implementation this will be non-zero
and will evaluate to TRUE, however it seems a bit odd and not
completely necessary to the logic of the program).
- You are reading only the first element of the array, although
you are adding an increasing offset to it for each iteration of
the loop.
This really is getting silly.
So... Seen any good old computers lately?
How about them Altairs - ain't they something?
When I was a gaffer, we had to carry our card decks
uphill both ways to the card punch!
Regards,
Dave
--
dave04a (at) Dave Dunfield
dunfield (dot) Firmware development services & tools:
www.dunfield.com
com Collector of vintage computing equipment:
http://www.parse.com/~ddunfield/museum/index.html