There's one extra local variable (char *t) which is
a pointer: hardly
expensive by any metric. If you prefer, move the i initializer inside the
for loop construct. Same difference.
The loop uses the same number of conditionals as any
other example so far
(including yours, which doesn't work ;)
I guess you missed my original solution - look back a few messages,
it uses only one conditional, and only one local variable, has no
superflous assignments, nor goto's.
The "clever" one in my last message was an illustation, not my
solution.
- 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).
Your analysis somewhat (misses the point|is non-sequitur). The unary
construct is the entire reason this works.
It still stuffs an address into a conditional - it works, but it's
not pretty, nowhere near the goal of "structured" (remember structured
... this is a song about structured) and not something I would ever
consider using in production code.
- 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.
Perhaps this is an issue of precedence and compiler implementation, but
the way it works (at least under gcc) is as I suspected, which is that
counter i gets incremented after first being added to aryp. So it in fact
iterates the entire array from start to end.
* is higher precedence than '+' (K&R page 49 - I know this from memory -
scary). If your compiler does the '+' first, it's broken.
You had card punches? We had to cut holes into ours
with exacto knives.
Actually, when I last visited the Your university museum, the Curator
showed me some "manual" card punches - little steel blocks with holes
and a pin 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