在字符串中删除与某字符相同的字符,要求用字符数组作函数参数。程序运行结果如下:
Input a string:
hello, my friend!↙
Input a character:
!↙
Results:hello, my friend
在空白处填写适当的表达式或语句,使程序完整并符合题目要求。
#include
void Squeeze(char s[], char c);
int main()
{
char str[20], ch;
printf("Input a string:");
gets(str);
printf("Input a character:");
ch = getchar();
Squeeze(str, ch);
printf("Results:%s", str);
return 0;
}
void Squeeze(char s[], char c)
{
int i, j;
for (i=j=0; ________; i++)
{
if (_________)
{
___________;
j++;
}
}
s[j] = '\0'; /* 在字符串s的末尾添加字符串结束标志 */
}
A. 第18行: s[i]!='\0'
第20行: s[i] != c
第22行: s[j] = s[i]
B. 第18行: s[i]!= ''
第20行: s[i] = c
第22行: s[i] = s[j]
C. 第18行: s[i]= '\0'
第20行: s[i] == c
第22行: s[j] = s[i]
D. 第18行: s[i]=='\0'
第20行: s[i] = c
第22行: s[i] = s[j]