#include #include #include #include #include #include #include using namespace std; using namespace std; int main() { const int n_cxx = 61 ; const int n_c = 32 ; typedef std::set cxx_words; cxx_words cxx_keywords; typedef std::set c_words; c_words c_keywords; string word; char file_name1[] = "cxx_words.txt"; ifstream input_file1(file_name1); if (!input_file1) { cerr << " Error in opening the cxx keyword file" << endl; exit(EXIT_FAILURE); } const int buffer_size = 80; char buffer[buffer_size]; cxx_words::iterator j; for (int i = 1; i < n_cxx; ++i) { input_file1.getline(buffer, buffer_size - 1); word = buffer; cxx_keywords.insert(word); } char file_name2[] = "c_words.txt"; ifstream input_file2(file_name2); if (!input_file2) { cerr << " Error in opening the c keyword file" << endl; exit(EXIT_FAILURE); } for (int i = 1; i < n_c; ++i) { input_file2.getline(buffer, buffer_size - 1); word = buffer; c_keywords.insert(word); } cout << "Type in a key word "; cin >> word; j = cxx_keywords.find(word); if (j != cxx_keywords.end()) cout << " key word " << word << " in C++ " << endl; else cout << " key word not in C++ " << endl; j = c_keywords.find(word); if (j != c_keywords.end()) cout << " key word " << word << " in C " << endl; else cout << " key word not in C " << endl; return(0); }