#include <stdio.h>
#include <string.h>
void delchars (char *str, char ch)
{
int len = strlen(str);
int i = 0;
while ( i < len )
{
if (str[i] == ch)
{
int j = i, width = 0;
if ( str[i+1] == ch)
width = 2;
else
width = 1;
while (j < len)
str[j] = str[j+width], j++;
}
i++;
}
}
int main ( )
{
char s1[128];
strcpy(s1, "HelloWorld");
delchars(s1, 'l');
printf("[%s]\n", s1); // [HeoWord]
delchars(s1, 'W');
printf("[%s]\n", s1); // [Heoord]
}
凸