int splitstr(char *sString,char szSearchItems[][100]) { int iItem=0; char* pSearchStr = sString; int dwSearchStrLen = strlen(sString); int i=0; int dwItemBeg = 0; for (i = 0; i<dwSearchStrLen;) { if(i==0) { while (i <dwSearchStrLen && ' '== sString[i]){++i;} dwItemBeg = i; } if (i == dwSearchStrLen-1) //到检索词结束 { if (i >=dwItemBeg)//有效项判断 { strcpy(szSearchItems[iItem],sString + dwItemBeg); iItem++; } break; } if (' ' != sString[i]) { ++i; continue; } if(' '==sString[i]) { strncpy(szSearchItems[iItem],sString+dwItemBeg,i - dwItemBeg); iItem++; ++i; while (i <dwSearchStrLen && ' '== sString[i]){++i;} dwItemBeg = i; } i++; } int j; for(j=0;j<iItem;j++) { printf("%s/n",szSearchItems[j]); } return iItem; }