| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Merits |
Hello Bill! Replying to a message of Bill Birrell to Darin Mcbride: BB> Hi Darin, BB> while (*s) putc(*s++, stdout); BB> Pre-increment would get this wrong. Post-increment does it right. BB> Is that not a merit? You've also moved the increment from the while() (where we've had it all along) to a new location. Some people call this "thinking outside the box". However, we were intending to compare generic for() and while() loops, showing how the obvious solutions weren't always so obvious. You're simply proving what we've said all along: don't muck with loops without really trying. I still favour for() loops for this type of thing. Everything becomes way more obvious, then. for (s = xyz; *s != '\0'; ++s) putc(*s, stdout); No ambiguities here. Nothing to miss (depending on how much of a hurry I'm in, or how big your while loop is, I might miss the fact that s is being incremented in it...). Darin ---* Origin: Tanktalus' Tower BBS (1:250/102) SEEN-BY: 633/267 270 @PATH: 250/102 99 10/345 106/1 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™.