Sunday, July 12, 2009

Write a "c' prog to accept two string&prog should delete char similar in both the string&print remain strings

#include %26lt;stdlib.h%26gt;





main( int argc, char **argv )


{


char *s1 = argv[1];


char *s2 = argv[2];


int i;


char *cp;


int count[256];





memset( count, 0, sizeof( count ) );


for( cp = s1; *cp; cp++ )


count[*cp]++;


for( cp = s2; *cp; cp++ )


count[*cp]++;





printf( "unique characters in s1: " );


for( cp = s1; *cp; cp++ )


if( count[*cp] == 1 )


printf( "%c", *cp );


printf( "\nunique characters in s2: " );


for( cp = s2; *cp; cp++ )


if( count[*cp] == 1 )


printf( "%c", *cp );


printf( "\n" );


}


No comments:

Post a Comment