read file in C++
- by Amm Sokun
I am trying to read a list of words from a file in C++. However, the last word is read twice. I cannot understand why it is so. Can someone help me out?
int main () {
ifstream fin, finn;
vector<string> vin;
vector<string> typo;
string word;
fin.open("F:\\coursework\\pz\\gattaca\\breathanalyzer\\file.in");
if (!fin.is_open())
cout<<"Not open\n";
while (fin) {
fin >> word;
cout<<word<<endl;
vin.push_back(word);
}
fin.close();
}