#include <stdio.h>
#include <strings.h>
void eatspaces(char *str)
{
int i = 0;
int j = 0;
while ((*(str + i) = *(str + j++)) != '\0')
if(*(str + i) != ' ')
i++;
return;
}
int main()
{
char array[32] = "hello linux world";
printf ("before eat spaces : %s\n", array);
eatspaces(array);
printf("after eat spaces : %s\n", array);
return 0;
}
[beyes@groad.net c]$ ./eatspaces
before eat spaces : hello linux world
after eat spaces : hellolinuxworld
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |