Code:
void testformatch(char pattern[],int pat_count,char buffer[],int buf_count)
{
while( pattern[pat_count] == buffer[buf_count] )
{
pat_count++;
buf_count++;
}
if(pattern[pat_count]=='\0')
{
printf("match\n");
pat_count=0;
}
else
{
pat_count=0;
}
}
I am trying to play with a simple algorithm to find a string for some reason Ican't get it to find it if they are exactly the same.
ie if pattern="ab2";
and buffer="ab2";
it won't give me a match.
Code:
int main(void){
char buffer[]="abc1";
char pattern[]="abc1";
int pat_count=0;
int buf_count=0;
while( (buffer[buf_count]) != '\0' )
{
testformatch(pattern,pat_count,buffer,buf_count);
buf_count++;
}
return 0;
}