/* To check the pattern exist or not */
#include< stdio.h>
#include< conio.h>
void main()
{
	char a[100],b[100],z[100],*pa,*pb,*pc,*pz;
	int count=0;
	pa=&a[0];   /* OR can be written as   pa=a */
	clrscr();
	printf("enter the text\n");
	for(;(*pa=getchar())!='$';pa++);
	*pa='\0';
	printf("enter the SEARCHING text\n");
	for(pb=b;(*pb=getchar())!='$';pb++);
	*pb='\0';
	/* copy to another array part */
	for(pz=z,pb=b,pb++;*pb;pb++,pz++)
	*pz=*pb;
	/* check the pattern */
	*pz='\0';
	for(pa=a;*pa;pa++)
	{
		for(pc=pa,pz=z;*pz==*pc&&*pz;pz++,pc++);
		if(*pz=='\0')
		count++;
	}
	if(count==0)
		printf("the pattern not exist");
	else
		printf("the pattern exist");
	getch();
}
/*
	input : enter the text:	idly vadai poori$
		enter the SEARCHING text: vadai$

	output:	the pattern exist

	Exercise:1: count number of times the pattern occurs
*/