。。。C++ 中的文件 I/O 小问题。。O(∩_∩)O谢谢。。。。。。。。。。。。。。。。
/*我想让 让程序从文件中读取内容 ,然后在控制台 输出。。。*/#include<iostream>#include<string>#include<fstream>#include<cstdlib>using namespace std;struct list{ string name; double money;};int main(){ int num; ifstream infile; infile.open("表单.txt"); if(!infile.good()) cout << "打开文件失败\n"; else { cout << "打开文件成功\n"; infile >> num; list *p = new list [num]; while(infile.good()) { for(int j = 0; j < num; j++) { infile >> p[j].name; infile >> p[j].money; } } if(infile.eof()) cout << "读取结束\n"; for(int j = 0; j < num; j++) { cout << p[j].name << endl; cout << p[j].money << endl; } } infile.close(); return 0;}