#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void delspace(char s[],char newstr[])
{
int i;
int count=0;
for(i=0;i<strlen(s);i++)
{
if(s[i]!=' ')
{
while((s[i]!=' ')&&(i<strlen(s)))
{
newstr[count++]=s[i++];
}
newstr[count++]=' ';
}
}
newstr[count-1]='\0';
}
int main()
{
char s[]=" I LOVE YOU ";
char newstr[200];
delspace(s,newstr);
printf("%s\n",newstr);
puts(newstr);
for(int i=0;i<strlen(newstr);i++)
{
printf("%c",newstr[i]);
}
}
删除多余空格
最新推荐文章于 2022-10-19 21:30:20 发布