输入两个字符串A,B要求使用指针完成删除A中遇到的所有B字符串中的字符并输出最后删除后的A结果
供参考:
#include <stdio.h>
char* deleAllElemInStrB(char* A, char* B)
{
char *pa = NULL, *pb = NULL;
int table[256] = {0};
if (!A || !B) return NULL;
pb = B;
while (*pb) table[*pb++]++;
pb = pa = A;
while (*pa){
if (table[*pa])
pa++;
else
*pb++ = *pa++;
}
*pb = '\0';
return A;
}
int main()
{
char a[] = "hello world", *p;
char b[] = "her d";
p = deleAllElemInStrB(a, b);
printf("%s", p);
return 0;
}