Hello everyone;
Whats the problem in following code for searching a substring in a string. The code is here-
Code:
#include<stdio.h>
#include<stdlib.h>
void sarch( char *, int , char *, int );
void main()
{
int i;
char *str="thegreathero";
char *pattern="hero";
int m,n;
search(char *str,int m, char* pattern, int n);
printf("\n \n");
}
void search( char *x, int m, char *y, int n)
{
int i,j;
for(j=0;j<(n-m);++j)
{
for(i=0; i<m && x[i]=y[i+j]; ++i);
if(i>=m){
printf("\n match found at \n \n->[%d]\n->[%s]\n",j,y+j);
}
}