Hello, I have a text file where in each line is 3 words and 2 int type numbers. I'm doing search by word and I want to print out to the screen the whole line where that word was found (the words is repeated in some lines). My search looks like this:
 #include <vector> 
using namespace std; 
int main(){
      vector <string> words; 
      string str, paieska;
              ifstream fin("duom.txt"); 
                while (fin >> str) 
                { words.push_back(str); }
      cout<<"Iveskite paieskos zodi"<<endl; 
                for (int i = 0; i < words.size(); ++i){
                 if (paieska==words.at(i)){
                cout<<"Rasta: "<<words.at(i)<<endl<<i<<endl;}}
return 0;
 system("pause"); }
How to print line(s) where I found that word?