| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Squares |
Hi Darin! :-)
DM> Given that they're in loops, they're the same.
You had already managed to convince me that the pointer variant is better
for string traversal. :)
[...]
DM> for (my_ptr = my_string; *my_ptr != '\0'; ++my_ptr)
DM> {
DM> /* use *my_ptr here */
DM> }
Better in the general case, I agree. I like the explicit check for the null
character.
[...]
DM> Yes - if you modify target. The theory would be that finding where
DM> you used "target" wrong in this loop is easier than in a loop with
DM> indexes. ANYWHERE you use "target" in this loop is
incorrect, while
DM> you need to examine the index-based equivalent very, very closely to
DM> figure out which use is wrong.
Ah yes.
PS>> Yeah, that looks bad.
DM> Especially when the message editor wordwraps it. :-)
The formatting looked okay on my end. ;)
PS>> What I meant was that all the string traversal "by
hand" I needed so
PS>> far was done via strchr(3) and strrchr(3).
DM> Hmmm - fair enough. You've never needed to do encoding/decoding,
DM> obviously ;-)
Nope, I'd use library functions for that when available. All the heavier
string processing in C I've done so far was parsing, and even that mostly
via lex and yacc.
The one thing I don't like about C is its string handling. It fits with the
rest of the language, though, which uses rather shallow abstractions
throughout.
Ciao
Pascal
--- Msged/LNX 6.1.1
* Origin: SYS 64738 (1:153/401.2)SEEN-BY: 633/267 270 @PATH: 153/401 307 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™.