#include <iostream>
#include <fstream>
#include <set>
#include <string>
typedef std::set<std::string> Dictionary;
void lookup(const Dictionary& Set, const std::string& word)
{
Dictionary::const_iterator it = Set.find(word);
std::cout << word << ": " << (it != Set.end() ? "present" : "not present") << std::endl;
}
int main()
{
Dictionary set;
std::ifstream file("file.txt");
std::string str;
while(getline(file, str))
{
if(str.length() != 0)
{
std::cout << "inserting " << str << " in dict" << std::endl;
set.insert(str);
}
}
file.close();
std::string word("lol");
lookup(set, word);
}
|