去除字符数组中的空格
#include<stdio.h>
#include<string.h>
int main(){
char str[] ="I want nothing else in this life than to be with you" ;
int i, j ;
for ( i = 0; str[i] !='\0'; i++)
{
if (str[i] != ' '){
continue;
}
else{
for ( j = i; j < strlen(str); j++)
{
str[j] = str[j + 1];
}
}
}
printf("%s \n",str);
printf("数组长度是%d位(空格不算,休止符不算)\n", strlen(str));
printf("算上空格和休止符的长度是%d位",sizeof(str));
return 0;
}