我有一個簡單的文件讀取問題。我有四個四行長的T/F,一開始就有一個計數。我用myfile >> count和myfile >>值讀取數值,計數完成後離開行並轉到下一行,但出於某種原因,我遇到了第三行的問題。不知道如何在這裏獲取數據文件...感謝您的期待!C++從文件環讀取亂碼
int main() {
ifstream myfile;
int count;
string value;
myfile.open("branches.txt");
while(!myfile.eof()) {
myfile >> count;
cout << count << endl;
while(count > 0) {
myfile >> value;
count--;
//cout << value;
}
myfile >> count;
}
system("pause");
return 0;
}
你能否用文件的確切內容更新這篇文章? –