tchar string 截取子串

2024-12-27 16:36:16
推荐回答(1个)
回答1:

#include
#include
#include
#define MAX_PATH 260
#define _UNICODE //本行可有可无
TCHAR path1[MAX_PATH]=_T("E:\\folder\\watch folder");
TCHAR path2[MAX_PATH]=_T("watch folder");
TCHAR *p;
int main() {
p=_tcsstr(path1,path2);
if (p==(TCHAR *)path1+(_tcslen(path1)-_tcslen(path2))) {
_tprintf("[%s] end with [%s]\n",path1,path2);
} else {
_tprintf("[%s] NOT end with [%s]\n",path1,path2);
}
return 0;
}
//[E:\folder\watch folder] end with [watch folder]
//