[刷题] 字符串去空格

如题

1 #include<stdio.h>
2 int main() {
3     int i,j=0;
4     char a[]="How are you";
5     for(i=0; a[i]; i++)
6         if(a[i]!=' ') a[j++]=a[i];
7     a[j]='\0';
8     printf("%s\n",a);
9 }

 

posted @ 2021-07-29 14:55  cxc1357  阅读(31)  评论(0编辑  收藏  举报