#include <stdlib.h>
#include <string.h>
#define MAX 100
char bak_str[MAX];
void Del_Blank(char *p)
{
int i = 0;
int j = 0;
int flag = 0;
while(*(p + i) != '\0')
{
while ( *(p+i) == ' ' )
{
i++;
flag = 1;
}
if(1 == flag)
{
*(bak_str + j) = ' ';
j++;
flag = 0;
}
else
{
while ( (*(p + i) != ' ') && (*(p + i) != '\0'))
{
printf("start of the i:%d\n",i);
*(bak_str+j) = *(p+i);
j++;
i++;
}
}
}
bak_str[j] = '\0';
}
int main(void )
{
char strarr[MAX];
printf("please input string:\n");
fgets(strarr,MAX,stdin);
Del_Blank(strarr);
printf("after deal whith the string:\n");
puts(bak_str);
return 0;
}