TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Darin McBride
from: Bill Birrell
date: 2004-04-22 00:17:02
subject: Squares

> The while statement will always increment s such that
 > it points to the character after the nul, which means
 > it's pointing to space that's either unallocated (the
 > one byte after allocated memory is allowed to be
 > pointed at, but not dereferenced, unlike the byte
 > before allocated memory), or at least garbage.

    Dispute!

    What you say is true with pre-increment, but with post-increment it
evaluates *s and finds it false before it increments s past the nul byte.
Since the falsity terminates the loop, the incremented pointer is not
dereferenced by the loop. That would not occur until the next iteration. It
is permissible to point past the end, but not to dereference it once there.

    As you say, habit. Both methods have their merits. This is the merit of
post-increment.

Best Wishes,
Bill.

---
* Origin: Escan BBS (2:25/200)
SEEN-BY: 633/267 270
@PATH: 25/200 108 252/110 250/501 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.