Fstream with txt

i am trying to ask a user for a string which is pushed into vector. then i need to open the txt file and compare what the user wrote to the txt file.any ideas ? i know the basic fstream like getting lines or word and outputting but other than that. i am clueless??
closed account (Dy7SLyTq)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	vector<string> myvec;
	string line;

	cout<<"Line: ";
	getline(cin, line);
	myvec.push_back(line);

	ifstream file("whatever.txt")

	while(getline(file, line))
	{
		if(myvec[0] == line)
			cout<<"match"<< endl;
	}
}
Topic archived. No new replies allowed.