编一个函数,输入一个字符串,要求做一个新字符串,把其中所有的一个或多个连续的空白字符都压缩为一个空格。这里所说的空白包括空格、' '、' '、' '。例如原来的字符串是:
This Content hoho is ok ok? file system uttered words ok ok ? end.
压缩了空白之后就是:
This Content hoho is ok ok? file system uttered words ok ok ? end.
1 #include <stdio.h> 2 int judge_char(char ch) 3 { 4 int result; 5 switch(ch) 6 { 7 case ' ':result = 0;break; 8 case ' ':result = 0;break; 9 case ' ':result = 0;break; 10 case ' ':result = 0;break; 11 default:result = 1; 12 } 13 return result; 14 } 15 16 char *shrink_space(char *dest, const char *src, int n) 17 { 18 int i = 0; 19 char *tmp = dest; 20 while(i < n && *src != '