Friday, 25 January 2013

Remove character from one string which matches in other


eg.s1="abcde" ,s2="xyzab" then result "cde".




#include<stdio.h>
#include<conio.h>
void main()
{
char a[10],b[10];
int i,j,k;
for(i=0;i<10;i++)
a[i]='\0';

printf("enter string a:");
scanf("%s",&a);
printf("enter string b:");
scanf("%s",&b);
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
if(a[i]==b[j])
{
for(k=i;k<10;k++)
a[k]=a[k+1];

}
}
}

printf("%s",a);
getch();
}


No comments:

Post a Comment