A window pops up saying: "Unhandled exception at x61D735BA (msvcp120d.dll) in Project7(2).exe: 0xC0000005: Access violation writing location 0x00000000.
#include <iostream>
#include <fstream>
usingnamespace std;
struct PERSON
{
char Name[50];
int Age;
float Gpa;
};
int main ()
{
PERSON *ptr;
int lines;
ifstream f("inf.txt"); //change to your file name
f >> lines; // 5 to lines, need not print it
ptr = new PERSON [lines];
for (int i = 0; i < lines; i++)
{
f >> ptr[i].Age;
f >> ptr[i].Gpa;
f.getline(ptr[i].Name, 50, '\n');
}
for (int i = 0; i < lines; i++) // following are printed in console window
cout << "name: " << ptr[i].Name << " age: " <<ptr[i].Age << " gpa: " << ptr[i].Gpa << endl;
return 0;
}