#include<stdio.h>
#include
void str(char* s);
int main(void)
{
char ch[] = “a dgjdkl gfdf b”;
str(ch);
printf("%s\n",ch);
system(“pause”);
return 0;
}
void str(char* s)
{
char* q = s;//q初始化不能为null 否则*q=*s为非法访问
while (*s != ‘\0’)
{
if (*s != ’ ')
{
*q = *s;
q++;
s++;
}
else
s++;
}
*q = ‘\0’;
s = q;
}
字符串删除空格
最新推荐文章于 2024-04-27 18:00:04 发布