Lorsque j'essaie d'exécuter mon programme, j'obtiens une erreur en disant que ld a renvoyé 1 état de sortie et je ne peux pas comprendre pourquoi. J'ai vérifié toute l'orthographe et le type de variables mais cela ne fonctionnera toujours pas. De plus, l'erreur est sur la ligne où j'appelle la fonction de rapport d'annulation.
merciCode:#include <iostream> #include <string> #include <fstream> using namespace std; const int STUDENTS = 10; const int SCORES = 5; void namesAndGrades(string name[], int id[], int grade[][SCORES], int oGrade[]); void letterGrd (string letter[], int oGrade[]); void output (string name[], string letter[], int id[], int grade[][SCORES], int oGrade[]); void highestGrade(int highScore, string highName, string name[], int oGrade[]); void searchName(string name[], string search); void report(string name[], string letter[], int id[], int grade[][SCORES], int oGrade[]); int main(){ int ids[STUDENTS]; string names[STUDENTS]; int grades[STUDENTS][SCORES]; int overGrade[STUDENTS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; string ltrGrade[STUDENTS]; int highGrade=0; string bestGrade; string searchTerm; int avg=0; namesAndGrades (names, ids, grades, overGrade); letterGrd (ltrGrade, overGrade); output (names, ltrGrade, ids, grades, overGrade); highestGrade (highGrade, bestGrade, names, overGrade); searchName (names, searchTerm); report (names, ltrGrade, ids, grades, overGrade); return 0; } void namesAndGrades(string name[], int id[], int grade[][SCORES], int oGrade[]){ char o; ifstream inFile; inFile.open("data121.txt"); if ("data121.txt"){ for(int x=0; x<STUDENTS; x++){ inFile >> id[x]>>o; getline(inFile, name[x], ','); for(int y=0; y<SCORES;y++){ inFile>>grade[x][y]>>o; oGrade[x]+=grade[x][y]; } } } inFile.close(); } void letterGrd (string letter[], int oGrade[]){ for(int i=0;i<STUDENTS;i++){ if (oGrade[i]>=90) letter[i]= "A"; else if (oGrade[i]<90 && oGrade[i]>=80) letter[i]="B"; else if (oGrade[i]<80 && oGrade[i]>=70) letter[i]="C"; else if (oGrade[i]<70 && oGrade[i]>=60) letter[i]="D"; else if (oGrade[i]<60) letter[i]="F"; } } void output (string name[], string letter[], int id[], int grade[][SCORES], int oGrade[]){ for (int x=0; x<STUDENTS; x++){ cout<< id[x]<<" "<<name[x]<<" "; for (int y=0; y<SCORES; y++){ cout<< grade[x][y]<<" "; } cout<< oGrade[x]<<" "<<letter[x]<<endl; } } void highestGrade(int bestScore, string highName, string name[], int oGrade[]){ for (int x=0; x<STUDENTS; x++){ if (oGrade[x] > bestScore){ highName = name[x]; bestScore = oGrade[x]; } } cout<<highName<<" "<<bestScore<<endl; } void searchName(string name[], string search){ bool found; cout<< "Please enter the name of the student you would like to look up: "; getline(cin, search); for (int x=0; x<STUDENTS; x++){ if (name[x]==search){ found=true; break; } } if (found) cout<<"Found the record of "<<search<<endl; else cout<< "No record found"<<endl; } void reprot(string name[], string letter[], int id[], int grade[][SCORES], int oGrade[]){ ofstream outFile; outFile.open("report121.txt"); for (int x=0; x<STUDENTS; x++){ outFile<<id[x]<<" "<<name[x]<<" "; for(int y=0; y<SCORES; y++){ outFile<<grade[x][y]<<" "; } outFile<<oGrade[x]<<" "<<letter[x]<<endl; } outFile.close(); }
-----