#include
#include
#include
void fun(char* src, char ch)
{
int len=strlen(src);
char *temp=(char *)malloc(len+1);
strcpy(temp,src);
while(*temp!='\0')
{
if(*temp != ch)
{
*src = *temp;
src++;
}
temp++;
}
*src='\0';
free(temp);
}
int main()
{
char *src="This is an example!";
char ch='e';
printf("before funed, the string is:%s\n",src);
fun(src, ch);
printf("after funed, the string is:%s\n",src);
system("pause");
return 0;
}
void fun(char* str, char chr)
{
char *p, *q;
p = q = str;
while(*p != '\0')
{
if(*p != chr)
*q++ = *p++;
else
p++;
}
*q = '\0';
}