// Copyright 2005 Daniel Cer (daniel.cer@cs.colorado.edu) // // This work is licensed under the Creative Commons Attribution-NonCommercial- // ShareAlike License. To view a copy of this license, visit // http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to // Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, // 94105, USA. #include #include #include #include #include using namespace std; int main(int argc, char *argv[]) { if (argc != 3) { cerr<<"Usage:\n\t"< entries; // read in the entries ifstream istrm(file_name); for (string line; getline(istrm, line); ) { entries.push_back(line); } istrm.close(); // try to find the first match vector::iterator iter = find(entries.begin(), entries.end(), term); // check to see if there are any matches if (iter == entries.end()) { cerr<<"Search term not found.\n"; return -2; } // locate all of the remaining matches for ( ; iter != entries.end(); iter = find(++iter, entries.end(), term)) { cout<<"found match on line: "<<(iter-entries.begin())+1<