为了账号安全,请及时绑定邮箱和手机立即绑定

 getline(inFile, p[i].name);      //未找到匹配的重载函数 头文件什么都有,错误在哪啊?

 getline(inFile, p[i].name);      //未找到匹配的重载函数 头文件什么都有,错误在哪啊?

C++
xungeer29 2017-10-10 13:26:23
#include<iostream>#include<fstream>#include<cstdlib>#include<string>using namespace std;struct Patron{ char name[20]; double money;};int main(){ cout << "请输入捐献者数目"; ifstream inFile; inFile.open("homework6_9.txt"); if (!inFile.is_open()) {  cout << "Could not open the file." << endl;  exit(EXIT_FAILURE); }  int num; inFile >> num; inFile. get(); char ch; inFile >> ch; Patron *p = new Patron[num];  for (int i = 0; i < num; i++)  {   inFile.get();   getline(inFile, p[i].name);                                   //未找到匹配的重载函数   inFile >> p[i].money;  }  cout << "Geand Patrons" << endl;  int count1 = 0;  int count2 = 0;  for (int i = 0; i < num; i++)  {   if (p[i].money > 10000)   {    cout << p[i].name <<" , "<<p[i].money<< endl;    count1++;   }   if (count1 == 0)    cout << "none" << endl;  }  cout << "Other Patrons";  for (int i = 0; i < num; i++)  {   if (p[i].money <= 10000)   {    cout << p[i].name << " , "<<p[i].money<<endl;    count2++;   }   if (count2 == 0)    cout << "none" << endl;  } inFile.close(); return 0;}
查看完整描述

1 回答

?
xungeer29

TA贡献46条经验 获得超20个赞

解决了,问题好多,感觉自己好蠢。。。。。。。。。。。


查看完整回答
反对 回复 2017-10-10
  • 1 回答
  • 0 关注
  • 2132 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信