Searching through a file
I'm wondering if anyone could help me find out how to search through a file. I know how to read a file, write to one etc, but am not sure how to find a specific word within a file and then return it.
I've done a search but cannot seem to find anything:(
Please could somebody help?
Thanks a lot,
it's sort of like searching an array of strings to find the one you want.
declare an ifstream to read the file
declare a string to acting as a holding variable
declare a string to act as the target variable
search the file using a loop
each time through the loop read a new word into the holding variable and compare it to the target variable. If they are the same do something. If they are different do something different.
Thanks for your reply :)
What do you mean by holding and target variables? Are those just normal variables with different purposes?