Write a C program which does wildcard pattern matching algorithm
Given two strings where first string may contain wild card characters and second string is a normal string. Write a function that returns true if the two strings match. The following are allowed wild card characters in first string.
* –> Matches with one or more instances of any character or set of characters.
? –> Matches with any single character.
For example, here “f?rmc*” matches with “firmcodes” string. Because it use two ‘*’ characters and single ? which indicates set of characters unknown and single character not known respectively.
bool WildCmp(char *pattern, char *string);
printf("! Match Found");
printf("! Match Not Found");
bool WildCmp(char *pattern, char *string)
if(*pattern=='\0' && *string=='\0') // Check if string is at end or not.
if(*pattern=='?' || *pattern==*string) //Check for single character missing or match
return WildCmp(pattern+1,string) || WildCmp(pattern,string+1); // Check for multiple character missing
- Write a C program to reverse the words in a sentence in place
- Write your own trim() or squeeze() function to remove the spaces from a string
- Write a C program to reverse the string without using strrev() ?
If you like this Article, then don’t forget to Click on Social likes buttons.