Prog#154: delete the pattern

/*
delete the pattern
Program#154
*/
#include<stdio.h>
main()
{
char a[50],b[50],c[100];
int i,j,l,k;
for(i=0;(a[i]=getchar())!='$';i++);
a[i]='\0';
for(i=0;(b[i]=getchar())!='$';i++);
b[i]='\0';
l=0; j=0;
for(i=0;a[i];i++);
{
k=i;
for(j=0;(b[j]==a[k]&&b[j]!='\0'); j++);
k++;
if(b[j]=='\0')
i=k;
else
{
c[l]=a[i];
l++;
}
}
c[l]='\0';
for(i=0;c[i];i++);
printf("%c",c[i]);
}