Code:
/* squeeze: modified to remove any matching chars of string2 from string1 */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char * squeeze(char * s1 , char * s2 );
int main(int argc, char **argv)
{
if( argc != 3 )
printf( "Usage: %s S1 S2, where any characters in S1 that are in S2 are deleted\n" , argv[ 0 ] );
else
printf( "%s\n" , squeeze( argv[ 1 ] , argv[ 2 ] ) );
return 0;
}
char * squeeze(char * s1 , char * s2 ){
int i , j , k = 0 , found = 0;
char * new_string = malloc( strlen( s1 + 1 ) );
for( i = 0; i < strlen( s1 ); ++i){
for( j = 0; j < strlen( s2 ); ++j){
if( s1[ i ] == s2[ j ] )
++found;
}
if( !( found ) )
new_string[ k++ ] = s1[ i ];
found = 0;
}
new_string[ k ] = '\0';
return new_string;
}
heres the new code. does anybody see any issues? please let me know!