#include<iostream>
using namespace std;
bool PathernMatch(char *pat, char *str)
{
	char *s = NULL;
	char *p = NULL;
	bool star = false;
	bool bBreak = false;
	do
	{
		bBreak = false;
		for (s = str, p = pat; *s; ++s, ++p)
		{
			switch (*p)
			{
			case ‘?‘:
				break;
			case ‘*‘:
				star = true; //出现*匹配符
				str = s;
				pat = p;
				if (!*++pat)
					return true;
				bBreak = true; //退出循环
				break;
			default:
				if (*s != *p)
				{
					if (!star)
						return false;
					str++;
					bBreak = true;
				}
				break;
			}
			if (bBreak) //退出循环 重新开始循环
				break;
		}
		if (bBreak == false)
		{
			if (*p == ‘*‘)
				++p;
			return (!*p);
		}
	} while (true);
}
int main()
{
	char a[100] = "\\Device\\*\\Content.IE5\\index.dat";
	char c[100] = "\\Device\\*\\Content.IE5\\*\\index.dat";
	char b[100] = "\\Device\\Harddiskvolume\\Content.IE5\\Femporary Internet Files\\Content.IE5\\index.dat";
	char d[100] = "\\*\\Content.IE5\\index.dat";
	char e[100] = "\*层图层\*顶";
	char f[100] = "一层图层";
	char g[100] = "二层图层";
	char h[100] = "二三层图层";
	char i[100] = "二搜索三层图层顶顶顶";
	cout << PathernMatch(e, f) << endl;
	cout << PathernMatch(e, g) << endl;
	cout << PathernMatch(e, h) << endl;
	cout << PathernMatch(e, i) << endl;
	return 0;
}
原文:https://www.cnblogs.com/Pond-ZZC/p/11881709.html