C++状态-1073741676

-5 c++ codeblocks

我在网上做了一些研究,但没有找到-1073741676Code::Blocks 显示的错误代码的解释。

\n\n

确切的错误消息是Process terminated with status -1073741676 (0 minute(s), 8 second(s))

\n\n

对于这个精确的状态是否有一个全局的、恒定的解释,或者它是否会随着编译器、IDE 或任何其他变量的变化而改变?

\n\n

代码(尽可能少):

\n\n

主程序

\n\n
    int n(0), choix(0);\n    string dis;\n    // Nobel* laureats = saisie(n); // Saisie \xc3\xa0 la main\n\n    Nobel* laureats = lecture(n);\n    cin >> dis;\n    cout << agemoyen(laureats, n, dis) << endl;\n
Run Code Online (Sandbox Code Playgroud)\n\n

诺贝尔.h

\n\n
#ifndef NOBEL_H_INCLUDED\n#define NOBEL_H_INCLUDED\n\n#include <string>\n\n\nstruct Nobel\n{\n    std::string nom, discipline;\n    int annee, age;\n    std::string pays;\n};\nint agemoyen(Nobel* NO, int n, std::string dis);\nNobel* lecture(int& n);\n\n#endif // NOBEL_H_INCLUDED\n
Run Code Online (Sandbox Code Playgroud)\n\n

诺贝尔.cpp

\n\n
int agemoyen(Nobel* NO, int n, string dis){\n    int ages(0);\n    int total(0);\n\n     for(int i = 0 ; i < n ; i++){\n        if(NO[i].discipline == dis){\n            ages += NO[i].age;\n            total++;\n        }\n    }\n    ages /= total;\n\n    return ages;\n}\n\nNobel* lecture(int& n){\n    Nobel* laureats;\n\n    ifstream fichier("tp7nobel.txt", ios::in);\n\n    if (fichier.is_open()) {\n        fichier >> n;\n\n        cout << n << endl;\n        laureats = new Nobel[n];\n\n        for(int i = 0 ; i < n; i++){\n            fichier >> laureats[i].nom >> laureats[i].discipline >> laureats[i].annee >> laureats[i].age >> laureats[i].pays;\n            cout << i << ")" << laureats[i]. nom << endl;\n        }\n        fichier.close();\n    }else{\n        cerr << "Impossible d\'ouvrir ce fichier." << endl;\n    }\n\n    return laureats;\n}\n
Run Code Online (Sandbox Code Playgroud)\n

Mih*_*ayl 5

-1073741676 是十六进制值 0xC0000094 - Windows 上整数除以零异常代码

代码:c0000094 说明:EXCEPTION_INT_DIVIDE_BY_ZERO

更新 我想你必须total在使用它之前检查是否不为零:

if (total) {
    ages /= total;
}
Run Code Online (Sandbox Code Playgroud)