in need help with accessing data members from an array of structures using pointers

# include <iostream>
# include <fstream>
const int SIZE = 20;
using namespace std;

typedef struct student
{
int stid,t1,t2,t3;
float avg;

}stud[SIZE];

student setstud(ifstream &);
void print(stud);

int main()
{
ifstream st("pr2data.txt");
stud s;
for(int i = 0;i<SIZE;i++)
{s[i] = setstud(st);}
stud *ptr_struct1;
ptr_struct1 = &s;
return 0;
}

student setstud(ifstream &student_in)
{
student st_info;
student_in>>st_info.stid>>st_info.t1>>st_info.t2>>st_info.t3;
return st_info;
}
Last edited on
Topic archived. No new replies allowed.