I have a question about structures, as I was programming some code and after I added a structure the program always crash, so I isolated a small part of it and I found that struct STUDENT is the cause of it.
when I declare the array of STUDENT students [MAX] in main the program crashes and I have no idea why, the program only runs when I
1.Change subjects2 in STUDENT to not a array. However I do need to store more than one subject that belongs to a student
2.Declare STUDENT in main not as a array. I need an array as I have to store possibly a large amount of students.
Is there possibly somewhere wrong with my declaration? I kindly ask for some help, thank you in advance.
#include<iostream>
using namespace std;
const int MAX = 100;
enum Grade {HDist, Dist, Credit, Pass, Fail};
struct assessment_Task
{
char Title_Name[MAX];
int Weight;
int Mark;
double A_Mark;
};
struct SUBJECT
{
char subject_Code[MAX];
char subject_Title[MAX];
int No_Assess_Task;
assessment_Task AT [MAX];
int finalMark;
Grade grade;
};
struct STUDENT
{
char Name[MAX];
int ID;
char Subjects_Taken[2][50];
SUBJECT subjects2 [MAX];
};
int main()
{
STUDENT students[MAX];
}