编写函数fun(),其功能是从s所指的字符串中删除给定的字符。同一字母的大、小写按不同字符处理。例如,若程序执行时输入字符串为turbo c and borland c++,从键盘上输入字符n,则输出后变为turbo c ad borlad c++。如果输入的字符在字符串中不存在,则字符串照原样输出。 #include<stdio.h> #include<string.h> void fun(char s[],char c)
main()
static char str[]="turbo c and borland c++"; char ch; printf("原始字符串:%s\n",str); printf("输入一个字符:"); scanf("%c",&ch); fun(str,ch); printf("str[]=%s\n",str);
【参考答案】
char *p=s; int i=0; while(*p){ if(*p!=c)s[i++......