All pastes #572786 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-06-17 20:59 UTC
rendered paste body
#include <stdio.h>
 
#define SIZE 20

void squeeze(char *z1, char *z2);
 
int main(){
    
    char s1[]= "abdcfffabcd\0";
    char s2[]= "fffffff\0";
   
	char *s1p = s1;
	char *s2p = s2;

    squeeze(s1p, s2p); /* Delete each character in s1 
                     that matches any character in string s2*/
 
	getchar();
}
 
 
void squeeze(char *z1, char *z2){
	 int found;
     char z3[SIZE];
     char *search;
	 char *result;
	 result = z3;
	 while (*z1 != '\0'){
		found = 0;
		search = z2;
		while (*search != '\0'){
			if (*z1 == *search)
				found = 1;
			search++;
		}
		if (found == 0){
			*result = *z1;
			result++;
		}			
		z1++;
	 }
	 *result='\0';
	 printf("%s\n", z3);	
}