// File: main1.C // // Sample program using STL list templates // Read the "spell" dictionary and make a list of words // that contain the substring "url" #include #include #include #include #include // Usual string library, for strstr #include // STL list template #include // STL string template, like BString #include "printall.h" main() { list L ; ifstream ifile("words") ; // "words" is filename of dictionary string str ; // Get strings from ifile that contain "url" // while (1) { ifile >> str ; if (ifile.eof()) break ; // str.c_str() gives the char * pointer to string in str // if (strstr(str.c_str(), "url")) { L.push_back(str) ; } } ifile.close() ; printall(L) ; }