Hi everyone. I decided to try and learn C++ on my own and i have ran into a problem and i just need slight kick in the butt. :)
I am just learning structures and i am practicing using some of the examples at the end of the chapter in my book. When i run the code below i get an error while running the program. The error is a windows error and says my program has encountered a problem and needs to terminate. I know the problem is with *student->Tests, but i am not sure what i am doing wrong.
Any help is greatly appreciated!
#include <iostream>
using namespace std;
struct studInfo
{
char Name[31];
short Idnum;
int* Tests;
float avg;
char grade;
};
void main()
{
short numTests, numStudents;
studInfo* student;
int* testScores;
cout << "How many Students? : ";
cin >> numStudents;
cout << "\nHow many test scores? : ";
cin >> numTests;
student = new studInfo[numStudents];
testScores = new int[numTests];
for ( int i = 0; i < numStudents; i++ )
{
cout << "\nEnter ID for student " << (i + 1) << ": ";
cin >> student->Idnum;
for ( int j = 0; j < numTests; j++ )
{
cout << "\nEnter test score " << (j + 1) << " for student " << i + 1 << ": ";
cin >> *student->Tests;
}
}
}