#include <stdio.h>
void fun (char *str)
{
/**********Program**********/
int i=0;char *p=str;
while (*p){if(*p!=' '){str[i]=*p;i++;}p++;}
str[i]='\0';
/*
char b[81];int i=0,j=0;
while(str[i]!='\0'){if(str[i]!=' '){b[j]=str[i];j++;}i++;}
for(i=0;i<j;i++){str[i]=b[i];}
str[i]='\0';
*/
/********** End **********/
}
main()
{
char str[81];
printf("请输入带有空格的字符串:\n");
gets(str);
fun(str);
printf("删除空格后的字符串是: %s\n",str);
}
04-29
4091
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-18
2162
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-29
3228
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)