#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <iterator>
#include <algorithm>
using namespace std;
int main() {
cout<<"Enter a word to be searched in the file words.txt:";
string wordForQuery;
cin>>wordForQuery;
// no files on ideone.com, using string
string inFile_contents = "there are some words in this file\nthat can be searched";
istringstream inFile(inFile_contents);
// ifstream inFile("words.txt");
istream_iterator<string> beg(inFile), end;
if(find(beg, end, wordForQuery) != end)
cout << "Found!\n";
else
cout << "Not Found!\n";
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxpdGVyYXRvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICAgIGNvdXQ8PCJFbnRlciBhIHdvcmQgdG8gYmUgc2VhcmNoZWQgaW4gdGhlIGZpbGUgd29yZHMudHh0OiI7CiAgICBzdHJpbmcgd29yZEZvclF1ZXJ5OwogICAgY2luPj53b3JkRm9yUXVlcnk7CiAgICAvLyBubyBmaWxlcyBvbiBpZGVvbmUuY29tLCB1c2luZyBzdHJpbmcKICAgIHN0cmluZyBpbkZpbGVfY29udGVudHMgPSAidGhlcmUgYXJlIHNvbWUgd29yZHMgaW4gdGhpcyBmaWxlXG50aGF0IGNhbiBiZSBzZWFyY2hlZCI7CiAgICBpc3RyaW5nc3RyZWFtIGluRmlsZShpbkZpbGVfY29udGVudHMpOwogICAgLy8gaWZzdHJlYW0gaW5GaWxlKCJ3b3Jkcy50eHQiKTsgCiAgICBpc3RyZWFtX2l0ZXJhdG9yPHN0cmluZz4gYmVnKGluRmlsZSksIGVuZDsKICAgIGlmKGZpbmQoYmVnLCBlbmQsIHdvcmRGb3JRdWVyeSkgIT0gZW5kKQogICAgICAgIGNvdXQgPDwgIkZvdW5kIVxuIjsKICAgIGVsc2UKICAgICAgICBjb3V0IDw8ICJOb3QgRm91bmQhXG4iOwp9