去掉字符串中的空格算法

3412阅读 0评论2012-08-20 gududesiling
分类:C/C++

/* Strip whitespace from the start and end of STRING.  Return a pointer
   into STRING. */
    char *
stripwhite (string)
    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;
}
上一篇:发个vim高手的动画图片
下一篇:syslog函数使用源码