Change the Ostream to cout then.
Still having trouble actually showing the output to the screen.
Outputs to the file s_rlpruett.txt like I thought you said you wanted?
Ostream << counter << " occurences of the word: " << userDefinedSearch;
Will output to the screen.
cout << counter << " occurences of the word: " << userDefinedSearch;
When you run my code, and for the file I created when you open the s_rlpruett.txt you get the following results:
1) occurence is on line: 1
2) occurence is on line: 5
3) occurence is on line: 20
4) occurence is on line: 32
5) occurence is on line: 32
34) occurence is on line: 145
34 occurences of the word: semper
Yes, but the standard commands are there for a reason. Very usefull!
Not familar with the peek command and a few others. Is there another way of implementing those
For input and output (cin, cout ect):
Alternatively though. Every time you call getline you know it is moving to a new line. So when you use get line you can dump the char and the peek (again my code was just for words not phrases) and increment the line counter by one. That is, increment the line character by one every while loop, because you know if it is going around again it is on a new line.
You have it right for the user to input.
Not sure of the getline usage also
So in the while loop change the
Which is just line cin >> stringLine (but from the file and not the user) to
Istream >> stringLine;
Right now I get an infinite Loop of whatever Word I enter.
Explain to your self in words this code you have:
What do you think that does?
while (Istream != 0)
But then in your while loop you will have to search the string:
for the word or phrase the user entered and then increment the counter by one, ect.
Go back through my code and make sure you understand what is going on (you can ignore the peek since you will not need it when you use getline).
To create the program you want (search for phrase) it only requires dumping the peek, change the cin>> to the getline (and the filestream >> to the getline) and use that find link and you are done). We are talking deleting the peek stuff, deleteing the if (check == '\n') and changing the if statement and you are done.