Search string in a text file and display it

Can someone help me on searching and displaying string in a text file.. Thanks, I'm using Dev C++.. :)
Last edited on
What kind of string is it?
1. one word
2. exact string that may include gaps, all in one line
3. one full line of the file
4. possibly several lines
number 2...
> number 2... (exact string that may include gaps, all in one line)

Read each line into a std::string using std::getline()
http://www.cplusplus.com/reference/string/getline/

For each line, test for the occurrence of the search string with std::string::find()
http://www.cplusplus.com/reference/string/string/find/
thanks.. how about number 4?

> how about number 4? ( possibly several lines)

Somewhat similar to 2, but use a sliding window (aka moving window) algorithm.
Topic archived. No new replies allowed.