0

I got this error, and I think it happed because of '\n'. However I can't find out the way to solve it. How shoud I change the code?

Debug Error! abort() has been called (Please Retry to debug the application)

This program is a grade management program, and errors occur in the process of receiving information. User enters the student's name, student number, number of subjects, etc. However, after entering a name, if I press Enter, the above error occurs. How can I solve it?

Here is the code of receiving information part.

#include <iostream>
#include <string>
using namespace std;

#define StdNum 2

struct Subject {
    string SubName;
    int Hakjum;
    string Grade;
    float GPA;
};
struct Student {
    string StdName;
    int Hakbun;
    Subject* Sub;
    int SubNum;
    float AveGPA;
};

inline void InputValue(string& str) {
    getline(cin, str);
    cin.ignore();
}

inline void InputValue(int& i) {
    cin >> i;
}

void InputData(Student* pSt, int StudentNum) {
    int i;

    for (i = 0; i < StudentNum; i++) {
        cout << "* " << i + 1 << "번째 학생 이름과 학번을 입력하세요.\n"; //This menas enter the student's name and student number.
        cout << "이름 : "; //This means name
        InputValue(pSt[i].StdName);
        cout << "학번 : "; //This means studentnumber
        InputValue(pSt[i].Hakbun);
        cout << "수강한 과목 수를 입력 : "; //This means number of subjects
        cin >> pSt[i].SubNum;
        cout << "\n\n";
}
Hpencil
  • 1
  • 2
  • 1
    You should run it through a debugger and see where it crashes. Search for how to use a debugger with your choice of IDE (visual studio, Clion, ...) – Ted Klein Bergman Apr 18 '22 at 08:02

0 Answers0