1. 单个字符串替换
void
my_str_replace(char* buf, char from, char to)
{
int i = 0;
while (buf[i]) {
if (buf[i] == from)
buf[i] = to;
++i;
}
}
2. 过滤前后空格
char*
stripwhite (char *string)
{
register char *s, *t;
for (s = string; whitespace (*s); s++)
;
if (*s == 0)
return (s);
t = s + strlen (s) - 1;
while (t > s && whitespace (*t))
t--;
*++t = '\0';
return s;
}
to be continued...
No comments:
Post a Comment