标签:
#include <stdio.h>
#include <string.h>
void delChar(char *s, char ch)
{
int i,j;
int len = strlen(s);
for(i = 0; i < len; i++)
{
if(s[i] == ch)
{
for(j = i; j < len; j++)
{
s[j] = s[j+1];
i--;
}
}
}
}
int main(int argc, char *argv[])
{
printf("Hello, world\n");
char s[100],*p ,*q ;
puts("输入小于100个字符:");
gets(s);
char del_x;
printf("输入要删除的字符:");
scanf("%c",&del_x);
/*for(p=s,q=s; *p!=‘\0‘; p++)
if(*p != del_x)
*q++=*p;
*q=*p;
puts(s);*/
delChar(s,del_x);
puts(s);
return 0;
}
标签:
原文地址:http://www.cnblogs.com/yll-sww/p/4582742.html