提问:c语言问题
网友回答:
完整的程序参考
#include <stdio.h>
#include <string.h>
void del_char(char *s,char c)
{
char c1,temp[1024];
int i,j;
i=j=0;
while(c1=s[i++])
{
if (c1!=c)
temp[j++]=c1;
}
temp[j]='\0';
strcpy(s,temp);
}
int main()
{
char s[1024];
char c;
printf("请输入一个字串:\n");
gets(s);
printf("请输入要删除的字符:\n");
c=getchar();
del_char(s,c);
printf("删除后的字串为:\n%s\n",s);
return 0;
}