Home Forums C Programming How to redo the same code using structs Re: Re: How to redo the same code using structs

#3598
GWILouisaxwzkla
Participant

A little correction. It seems you are passing arrays of names , id’s and crn into the function:


void addStudent (char name[SIZE][LENGTH], int id[SIZE], int crn[SIZE][4]);

so you would change your prototype to :


const int numberOfStudents = 20; //whatever
void addStudent ( STUDENT newStudent [ numberOfStudents ] );

and access the data members like this:


..........
int i = currentStudent;
printf ( newStudent [ currentStudent ].name ); //output the student name
printf ( "%i" , newStudent [ currentStudent ] .id ); //output the student id

my bad ………