String matching with * ( that matches with any ) in any of the two strings | CPP program for string matching with * ; Function to check if the two strings can be matched or not ; if the string don 't have *  then character at that position  must be same. ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool doMatch ( string A , string B ) { for ( int i = 0 ; i < A . length ( ) ; i ++ ) if ( A [ i ] != ' * ' && B [ i ] != ' * ' ) if ( A [ i ] != B [ i ] ) return false ; return true ; } int main ( ) { string A = " gee * sforgeeks " ; string B = " geeksforgeeks " ; cout << doMatch ( A , B ) ; return 0 ; }