Guest User

Untitled

a guest
Jun 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void remove_array(void *list,int index,int len){
  6.     int i;
  7.     if(index == 0){
  8.         for(i = 0; i < len; i++)
  9.             list[i]=list[i+1];
  10.         list[strlen(list)-1]='\0';
  11.     }
  12.  
  13.     if(index == strlen(list)-1) list[strlen(list)-1]='\0';
  14.  
  15.     if(index > 0 && index < strlen(list)-1){
  16.         for(i = index; i < strlen(list)-1; i++)
  17.             list[i]=list[i+1];
  18.         list[strlen(list)-1]='\0';
  19.     }
  20. }
  21.  
  22. void remove_string(char *s,char *param){
  23.     int i,j;
  24.  
  25.     for(i = 0 ; i < strlen(s); i++)
  26.         for(j = 0; j < strlen(param); j++)
  27.             if(s[i] == param[j]){
  28.                 remove_array((char *)s,i,strlen(s));
  29.                 i--;
  30.             }
  31. }
  32.  
  33. int main(){
  34.     char str[]="11A42BCA31?H%O^A$NG!";
  35.     char key[]="0123456789 ?%^$!";
  36.     remove_string(str,key);
  37.     printf("s= %s",str);
  38.  
  39.     system("pause");
  40.  
  41.     return 0;
  42. }
Add Comment
Please, Sign In to add comment