read specific line from txt

03/17/2015 22:11 RaZeRoR#1
can somebody help me please?
My problem is;

i have a txt file
i ask the user for 2 words(word1,word2), if there is a line in my txt file with both words, i have to cout the line which has both words...
e.g;

line1 car wood steel computer
line2 birds animals bikes trees
line3 sky water beach sun

user inputs word ( birds and trees) both birds and trees are in same line
how can i cout the specific line which has both words ?
03/17/2015 23:52 xinternet#2
i dont know how to program it in c++, but u should try the following:

loop(while true){
1. read a line
2. check for one word
3. if one word is in the line check for other word
4. both words in it = break; (exit loop) [cout: line]
5. start at 1. (if 4. doesnt stop the loop before)
}




since u want BOTH words in it, it doesnt matter which word u search first. there is no need to check both words, when not even one is in the line.
03/18/2015 00:19 bloodx#3
PHP Code:
std::fstream File;
    
File.open("Your .txt File");
    
std::string szLine;
    while (
std::getline(FileszLine))
    {
        
// use szLine.find