Fool's Garden

Talking about Windows Mobile and Embedded gadgets...Web counter
posts - 58, comments - 99, trackbacks - 0, articles - 4

去除字符串中的空格

Posted on 2005-03-30 15:32 Levins Dai 阅读(1139) 评论(3) 编辑 收藏
依稀记得是某个公司的面试小题目:

void erase_spaces (char *pStr)
{
        char *pW = pStr;
        while (*pStr != '\0')
        {
                if (*pStr != ' ') *pW++ = *pStr;
                ++pStr;
        }
        *pW = '\0';
}