當前位置:成語大全網 - 書法字典 - 數組中的字典如何刪除字符?

數組中的字典如何刪除字符?

# include & ltstdio.h & gt

# include & ltmalloc.h & gt

# include & ltstring.h & gt

void delete char(char * s,char *c)

{

int s length = strlen(s);

int c length = strlen(c);

int * target =(int *)malloc(s length * sizeof(int));

for(int I = 0;我& lt長度;i++)

{

target【I】= 0;

}

for(I = 0;我& lt長度;i++)

for(int j = 0;j & lt長度;j++)

{

if(s【I】= = c【j】)

target【I】= 1;

}

for(I = 0;我& lt長度;i++)

printf(“% d“,target【I】);

printf(“\ n“);

for(I = 0;我& lt長度;i++)

{

if(target【I】= = 1)

{

for(int j = I+1;j & lt長度;j++)

{

if(target【j】= = 0)

{

s【I】= s【j】;

s【j】=‘\ 0‘;

target【j】= 1;

打破;

}

}

}

}

免費(目標);

}

void main()

{

char a【】=“abcdef“;

char b【】=“BD“;

delete char(a,b);

printf(“% s \ n“,a);

}