大家好。我又来咯。。cin类的问题。。
#include<iostream>#include<string>#include<fstream>using namespace std;struct list{ string name; double money;};int main(){ int num; ofstream outfile; outfile("表单.txt"); cout << "输入捐款人的数目: \n"; (cin >> num).get(); list *p = new list [num]; // p 首先是结构体类型的指针 然后动态分配了 num个结构体类型的 数组 for(int j = 0; j < num; j++) { cout << "输入第" << j+1 << "人的" << "name : \n" ; cin << p[j].name; cout << "输入捐款的数目:\n"; cin << p[j].money; }