1

Пишу код чтобы он искал введеное слово в файле и возвращал значение (false или true в зависимости от наличия слова), но программа всегда возвращает false в независимости от наличия слова в данном файле. Что не так с кодом?

#include <algorithm>
#include <iostream>
#include <fstream>
#include <string>
#include <iterator>

using namespace std;

int main()
{
    string inputword;
    string words;
    cin >> inputword;
    ifstream fin("Words.txt");
    fin >> words;
    istream_iterator<string> eof;
    bool found = find(istream_iterator<string>(fin), eof, inputword) != eof;
    cout << found;
    system("pause");
}

0 Answers0