| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Squares |
> JB>>>> for( s=target ; *s ; s++ ) {
> BB>> char *s=target;
> BB>> while(*s++) {...};
> JB> but not equivalent.
> How so? These sure _look_ like they do the same
> thing.
No, they aren't exactly the same. To be identical the while version
would have to be:-
char *s = target;
while (*s != '\0') { ...; s++; (or ++s;)};
The elision with post-increment makes no practical difference as far as
I can see, but what Darin and Jasen said is true. It would have been an
error to pre-increment s, because that would attempt to dereference
unallocated memory.
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™.