【发布时间】:2011-06-28 05:24:43
【问题描述】:
我正在尝试从 C++ 文件中读取单词列表。但是,最后一个单词被读取两次。我不明白为什么会这样。有人可以帮帮我吗?
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();
}
【问题讨论】:
-
接受 == 点击最佳答案下的右标记(20 分钟后您询问)