온라인으로 약간의 연구를했지만 Code :: Blocks에 표시된 오류 코드 -1073741676
에 대한 설명을 찾지 못했습니다.C++ 상태 -1073741676
정확한 오류 메시지는 Process terminated with status -1073741676 (0 minute(s), 8 second(s))
입니다.
이 정확한 상태에 대한 전역적이고 지속적인 설명이 있습니까? 아니면 컴파일러, IDE 또는 다른 변수로 변경됩니까?
코드 (내가 할 수있는만큼 최소) :
MAIN.CPP
int n(0), choix(0);
string dis;
// Nobel* laureats = saisie(n); // Saisie à la main
Nobel* laureats = lecture(n);
cin >> dis;
cout << agemoyen(laureats, n, dis) << endl;
Nobel.h
#ifndef NOBEL_H_INCLUDED
#define NOBEL_H_INCLUDED
#include <string>
struct Nobel
{
std::string nom, discipline;
int annee, age;
std::string pays;
};
int agemoyen(Nobel* NO, int n, std::string dis);
Nobel* lecture(int& n);
#endif // NOBEL_H_INCLUDED
Nobel.cpp이
int agemoyen(Nobel* NO, int n, string dis){
int ages(0);
int total(0);
for(int i = 0 ; i < n ; i++){
if(NO[i].discipline == dis){
ages += NO[i].age;
total++;
}
}
ages /= total;
return ages;
}
Nobel* lecture(int& n){
Nobel* laureats;
ifstream fichier("tp7nobel.txt", ios::in);
if (fichier.is_open()) {
fichier >> n;
cout << n << endl;
laureats = new Nobel[n];
for(int i = 0 ; i < n; i++){
fichier >> laureats[i].nom >> laureats[i].discipline >> laureats[i].annee >> laureats[i].age >> laureats[i].pays;
cout << i << ")" << laureats[i]. nom << endl;
}
fichier.close();
}else{
cerr << "Impossible d'ouvrir ce fichier." << endl;
}
return laureats;
}
코드를 붙여 넣으십시오 : 당신이
total
여부를 확인해야 가정 이 그것을 사용하기 전에 0이 아닌EXCEPTION_INT_DIVIDE_BY_ZERO
UPDATE 여기, 그리고 그것을 [mcve] –
@PasserBy 코드를 Minimal, Complete 및 Verifiable 예제에 따라 추가하십시오. – epidoxe