猿问

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

#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;
}


xungeer29
浏览 2172回答 1
1回答

xungeer29

解决了,问题好多,感觉自己好蠢。。。。。。。。。。。
随时随地看视频慕课网APP
我要回答