>&,"-6ren"> >&,"-上面写着“Apple Mach-O Linker (Id) Error "readIt(std::_1::basic_ifstream >&," 有没有人看到它一直卡住的错误?非常感谢! #inclu-6ren">
gpt4 book ai didi

c++ - 我不断从 Xcode 收到一个错误,上面写着 "Apple Mach-O Linker (Id) Error "readIt(std::_1::basic_ifstream>&,"

转载 作者:行者123 更新时间:2023-12-02 11:03:31 24 4
gpt4 key购买 nike

上面写着“Apple Mach-O Linker (Id) Error "readIt(std::_1::basic_ifstream >&,"
有没有人看到它一直卡住的错误?非常感谢!

#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;

//PERRYI
// following: student's name, two test grades and final exam grade.
// It then prints this information to the screen.


const int NAMESIZE = 15;
const int MAXRECORDS = 50;
struct Grades // declares a structure
{
char name[NAMESIZE + 1];
int test1;
int test2;
int final;
char letter;

};

typedef Grades gradeType[MAXRECORDS];



void readIt (ifstream&,Grades [], int []);


int main()

{
ifstream indata;
indata.open("graderoll.txt");
int numRecord; // number of records read in
gradeType studentRecord;

if(!indata)
{
cout << "Error opening file. \n";
cout << "It may not exist where indicated" << endl;
return 1;
}

readIt(indata,studentRecord,&numRecord); // FILL IN THE CODE TO CALL THE FUNCTION ReadIt.

// output the information
for (int count = 0; count < numRecord; count++)
{
cout << studentRecord[count].name << setw(10)
<< studentRecord[count].test1
<< setw(10) << studentRecord[count].test2;
cout << setw(10) << studentRecord[count].final << endl;
}

return 0;
}



void readIt( ifstream& inData, Grades gradeRec[], int& total)
{
total = 0;

inData.get(gradeRec[total].name, NAMESIZE);
while (inData)
{
inData >> gradeRec[total].test1;// FILL IN THE CODE TO READ test1
inData >> gradeRec[total].test2;// FILL IN THE CODE TO READ test2
inData >> gradeRec[total].final;// FILL IN THE CODE TO READ final

total++; // add one to total

inData.ignore(81,'\n');// FILL IN THE CODE TO CONSUME THE END OF LINE
inData >> gradeRec[total].name;

total = (gradeRec[total].test1 + gradeRec[total].test2)*(.30) + (gradeRec[total].final * .40);
if (total <= 100 || total >= 90 )
cout << "A";
else if (total <= 89 || total >= 80)
cout << "B";
else if (total <= 79 || total >= 70)
cout << "C";
else if (total <= 69 || total >= 60)
cout << "D";
else
cout << "F";





}

}

有没有人看到它一直卡住的错误?非常感谢!

最佳答案

您的原型(prototype) void readIt (ifstream&,Grades [], int []);与您的功能不匹配 void readIt( ifstream& inData, Grades gradeRec[], int& total) .参数类型必须完全匹配。

关于c++ - 我不断从 Xcode 收到一个错误,上面写着 "Apple Mach-O Linker (Id) Error "readIt(std::_1::basic_ifstream<char,std::_1::char_traits<char>>&,",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27050378/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com