从msgBootforce []中找到一个单词,该单词出现在数组* dicoActuel中

时间:2019-07-16 13:47:45

标签: c

问题是,如果我仅插入一个单词,并且如果我插入多个单词,则此代码将不起作用,而对于最后一个单词则无效 我需要您的帮助:

void chercherScoreMotDansDico(char msgBootforce [], int* 
      maxCorrepondance, char* mot, char* dicoActuel, char* 
      bonResultatBootforce) {
        int i = 0;
        char *suiteChaine;
        char tmpMsgBootForce [3000] = {0};
        strcpy(tmpMsgBootForce, msgBootforce);
        mot = strtok (tmpMsgBootForce, " ");
        while (mot != NULL) {
            suiteChaine = strstr(dicoActuel, mot) ;
            if (suiteChaine != NULL) {
                suiteChaine --;
                if (*suiteChaine == ' ' || *suiteChaine == '\n' || *suiteChaine == '\0') {
                    suiteChaine);
                    suiteChaine= suiteChaine + strlen(mot);
                    suiteChaine);
                    suiteChaine++;
                    if (*suiteChaine == ' ' || *suiteChaine == '\n' || *suiteChaine == '\0')  {
                                ++i;
                    }

                }
            }

            mot = strtok (NULL," ");    
        }

        if (i >= *(maxCorrepondance)) {
            *(maxCorrepondance) = i;
            strcpy(bonResultatBootforce, msgBootforce);
        }

0 个答案:

没有答案