/*------------------------------------------------------------------------------
将字符串开始和末尾的连续空格删除,同时将字符串中间的多个空格删减只剩1个空格。
运行结果:"hello how are you"
------------------------------------------------------------------------------*/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>
void getnewstr(char a[])
{
int isbegin,front,back;
isbegin=1;
front=0;
back=0;
/**********Program**********/
/********** End **********/
if(a[front-1]==' ')
--front;
a[front]='\0';
}
int main()
{
char a[] = " hello how are you ";
printf("\"%s\"\n",a);
getnewstr(a);
printf("\"%s\"\n",a);
return 0;
}