#include
#include
void process(char *str)
{
int len = strlen(str);
char buff[len+1];
int count = 0;
char *p = str;
while(*p != '\0')
{
if(*p==' ' || *p=='\t')
{
p++;
continue;
}
else
{
buff[count] = *p;
count++;
p++;
}
}
buff[count] = '\0';
memcpy(str,buff,count);
}
int main()
{
char str[100];
printf("please input a string:");
gets(str);
process(str);
puts(str);
return 0;
}
可以使用strstr函数和strcat函数 结合完成
使用strstr函数完成待删除字符的定位 然后使用strcat进行连接 将待删除字符覆盖掉 即可完成删除