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

#3596
GWILouisaxwzkla
Participant

You really just need to group all your data together ( structs are handy for this purpose ). So if you have a function prototype like:


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

change it to:


void addStudent ( STUDENT newStudent );

when you need to access a member of the struct , just use the dot operator and use the data as usual:


..........
printf ( newStudent.name ); //output the student name
printf ( "%i" , newStudent.id ); //output the student id

not too much to the conversion …….