//输入一个字符串,把连续的空格合并成一个。
void remove_duplicate_space(char *p)
{
char *r=p, *w=p; //r: read, w: write
while (*r != '\0') {
if (*r!=' ' || *(w-1) != ' ')
{ *w = *r; w++; r++;}
else
r++;
}
if (r!=w) *w = '\0';
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment