dhilst

match.c

#include <stdio.h>


char *match(char *smaller, char *bigger)
{
char *addr, *smaddr;
smaddr = smaller;
for(; *bigger != 0; bigger++){
if(*smaller == *bigger){
addr = bigger;
while(*smaller == *bigger){
if(*(smaller+1) == 0)
return(addr);
if(*(bigger+1) == 0)
return(0);
smaller++; bigger++;
}
smaller = smaddr;
}
}
return 0;
}

int main(int argc, char **argv)
{
char *s1, *s2, *chk;
s1 = "Here is what I say for the METAL:"
" Hello"/*METAL*/" World!";
s2 = "Hello World";
chk = match(s2, s1);
printf("%s", chk);
return 0;
}

OUTPUT:
Hello World!