/*删除空格函数*/
void trim (char *str) { /*必须在main函数前边定义函数,否则会编译错误*/
char *tmp = str;
while (*str != 0) {
if (*str != 0x20) { /*空格的ASCII码是0x20*/
*tmp++ = *str;
}
str++;
}
*tmp = 0;
}
main () {
char s[100];
scanf ("%[^\n]", s); /*注意以回车结束的写法,%s不能接收空格*/
trim (s);
printf ("%s\n", s);
}