Basically in this program I am opening a text file (most likely a book or something).
I want the user to enter in a word or phrase they wish to search for. Then I want to output the file that was searched and what word or string was originally searched for.
I want to show each line of where the string searched occurs and show the line number in the file and show where in the line the string is located.
After the last line has been read, I want a report of how many times the entered word was found and how many total lines are in the file.
I want all of that written to a seperate file.
------------------------------------------------------------------------------------------
However, Im having trouble reading in the values and actually having it " Find" my word in the text.
This is what I have thus far :
Code:#include <iostream> #include <fstream> #include <string> using namespace std; int main() { string stringLine; string userDefinedSearch; ifstream Istream; ofstream Ostream; Istream.open("shakespeare.txt"); Ostream.open("data.txt"); cout << " Please enter what you are looking for : " ; getline(cin,userDefinedSearch); while ( Istream != 0) { cout << userDefinedSearch << endl; } Istream.close(); Ostream.close(); return 0; }



LinkBack URL
About LinkBacks


