#include
void fun(char s[],char c)
{int i,j;
for(i=0;s[i]!=0;i++)
{if(s[i]==c)
for(j=i;s[j]!=0;j++)
s[j]=s[j+1];
}
return s;
}
int main()
{
char str[80];
char ch;
gets(str);
scanf("%c",&ch);
fun(str,ch);
printf("%s\n",str);
return 0;
}
#include
#include
char *fun(char *str, char ch)
{
size_t len = strlen(str);
size_t i = 0, j;
while (i < len)
{
if (str[i] == ch)
{
printf ("%d\n", i);
j = i + 1;
while (str[j] != 0)
{
str[j - 1] = str[j];
++j;
}
--len;
continue;
}
++i;
}
str[i] = 0;
return str;
}
int main(int argc, char *argv[])
{
char str[] = "hello world!";
printf("%s\n", fun(str, 'l'));
return 0;
}
if(s[i]==ch)
continue;
else
s[j++]=s[i];
你上百度查嘛