代码功能
1、将关键字字符串以空格区分,分别放到strWrod字符串数组里。
2、循环比较strBody字符串里有没有strWrod数据里的关键字。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#include <windows.h> #include <stdio.h> void main() { TCHAR *strBody = {"This is test string,the word in 我爱你"}; TCHAR *lpCmdLine = {"我爱你 love string"}; TCHAR strWrod[100][10]; char strCmdLine[MAX_PATH]; strcpy(strCmdLine,lpCmdLine); //找到第一个关键字 char *pstrParam; pstrParam = strtok(strCmdLine," "); strcpy(strWrod[0],pstrParam); if (strstr(strBody,strWrod[0])) { printf("%s found...\n",strWrod[0]); } int i = 1; while (pstrParam) { //找到第二个关键字 pstrParam = strtok(NULL," "); if(pstrParam) { strcpy(strWrod[i],pstrParam); } if (strstr(strBody,strWrod[i])) { printf("%s found...\n",strWrod[i]); } i++; } } |
转载请注明:exchen's blog » 多项关键字循环比较