Work with text file

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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<string>
#include<fstream>
#include<stdlib.h>

#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;
     cin>>paieska;
  for (int i = 0; i < words.size(); ++i){
	if (paieska==words.at(i)){
        cout<<"Rasta: "<<words.at(i)<<endl<<i<<endl;}}
  fin.close();
  return 0;
   
 system("pause");
}

How to print line(s) where I found that word?
Topic archived. No new replies allowed.