1、写一个函数去掉字符数组中第一个字母以前的所有空格,并且将字母中间的多个空格变成一个空格,然后在主函数中调用这个函数。
如字符串:_ _ _ _ _ abc_ _ _ _de_ _ _ _fg_ _ _ _
调用函数后字符串变为:abc_de_fg
(注:为便于理解把例子中的下划线认为是空格)
你的程序大致如下:
#include <stdio.h>
void compress_space(char *p1,char *p2);
main()
{
char a[30]={" abc de fg "};
char b[30];
compress_space(a,b);
printf("%s\n",b);
}
void compress_space(char *p1,char *p2)
{
..............
}