| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Snippets ini.c |
From: Bob Stout
BS> This is at the heart of the argument for the "two pass"
BS> approach. Aside from the fact that it has a clearly obvious
BS> algorithm, many (most?) compiler libraries will have
BS> implemented strlen() in assembly which may make it faster
BS> than anything you can write in C.
Perhaps not, however. strlen() may be nothing more than the
use of strchr() to search for the zero terminator! If that is
the case, then we may simplify our function and use the standard
strchr() function to find the terminator and then work backward.
static char *notrail(char *string)
{
char *end;
if (string && *string)
{
for(end = strchr(string, 0) - 1;
isspace(*end) && (end >= string);
end--);
*++end = (char)0;
}
return string;
}
It is rather pretty this way, isn't it?
> kkuzba{at}centurytel.net http://home.centurytel.net/kkuzba
> Now more torches were being lit. A cask of wine was broached.
--- SoupGate-Win32 v1.05
* Origin: kkuzba{at}centurytel.net (2:292/516.666)SEEN-BY: 633/267 270 @PATH: 292/516 854 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™.