int main() { char *string = "hereheroherr"; char *pattern = "*hero*"; if(wildcard(string, pattern)==TRUE) { printf("\nMatch Found!\n"); } else { printf("\nMatch not found!\n"); } return(0); }
int wildcard(char *string, char *pattern) {
while(*string) { switch(*pattern) { case '*':
do {
++pattern;
}while(*pattern == '*'); if(!*pattern) return(TRUE); default :
if(*string!=*pattern)return(FALSE); break; } ++pattern; ++string; } while (*pattern == '*') ++pattern; return !*pattern; }
No comments:
Post a Comment