cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Word search from file to display whole l
Word search from file to display whole line
Sep 3, 2008 at 3:43pm UTC
poorguy
(1)
Hi Guy!
I am trying write a small program which search word from text file and display a matched word whole line. Can any body help me out please?
Thank you,
Poor Guy
Sep 3, 2008 at 4:12pm UTC
mahlerfive
(119)
You can use an ifstream to get input from files, and use the getline() function to get each line one at a time from the file. Then simply search the line you retrieved for the word you are looking for - if you find it, just print out the line.
ifstream:
http://www.cplusplus.com/reference/iostream/ifstream/
getline:
http://www.cplusplus.com/reference/iostream/istream/getline.html
Topic archived. No new replies allowed.