1 #include<stdio.h> 2 #include<stdlib.h> 3 4 void replaceBlank(char *str); 5 6 int main() 7 { 8 char str[32]; 9 gets_s(str,32); 10 replaceBlank(str); 11 puts(str); 12 system("pause"); 13 return 0; 14 } 15 16 void replaceBlank(char *str) 17 { 18 int old_length = 0;//原字符串的长度 19 int new_length = 0;//新字符串的长度 20 int blank_cnt = 0;//空格的个数 21 int i = 0;//原字符串的下标 22 int j;//新字符串的下标 23 24 if(str[i] == '