0

Can anybody help me on how to search a keyword in my text file. I read about eliza420 Thread but still don't get it.

If i have a text file named. "animals.txt" with a content of,
-------------------------------------------------------------------
Fish
Pig
Dog
Goat
Bird
-------------------------------------------------------------------
and in my c++ program a question will ask the user,
cout<<"Enter a animal: "<<endl;
will promt like this.
-------------------------------------------------------------------
Enter a animal: Dog
-------------------------------------------------------------------
When the user enters a Dog then the c++ program will search the keyword "Dog" from the text file "animals.txt".
If the keyword exist then it will promt as
-------------------------------------------------------------------
Enter a animal: Dog
Animal Dog found in our text file.
-------------------------------------------------------------------
if keyword not found in the list then it will promt as
-------------------------------------------------------------------
Enter a animal: Dog
Animal Dog not found in our text file.
-------------------------------------------------------------------


My problem is how to code this one. I know it's a quest simple problem. but i'm also a newbie about c++ coding.

Thank you,

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by thekashyap
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.