看下面的代码就明白了:
//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
char s[500];
int i,j,k;
printf("Please enter a string...\n");
gets(s);
for(j=i=0;s[i];i++)
if(s[i]!=' ')
s[j++]=s[i];
s[j]='\0';
printf("\nThe final result is:\n%s\n",s);
return 0;
}