我打算找出用户输入字符串的任何排列是否是文本文件中的有效单词,单词很少。
输入字符串后,没有任何反应!“如果” stmt 有什么问题或什么?另外,如果我写了一个执行的 else ,这意味着即使我输入了 list.txt 中存在的单词,也无法达到控制
我可以尝试什么来解决这个问题?
//check if any permutation of a user inputted word are in a pre defined text file
    #include <iostream>
    #include <fstream>
    #include <vector>
    using namespace std;
    int main(){
        cout<<"Enter a word to check for the presence of any
        << of its permutation in a file \n"; 
        string word; 
        cin>>word; 
        sort(word.begin(), word.end()); 
        vector<string> str; 
        do str.push_back(word);
        while( next_permutation(word.begin(),word.end()) );                  
        ifstream readFile("list.txt");
        string line;
        while(readFile>>line){
              for (int i = 0; i < str.size(); ++i){
                  if(line==str[i]){
                     cout << "found " << str[i] << endl;
                     break;
                  }
              }
        }
        system("pause");
        return EXIT_SUCCESS;
    }