Home › Forums › C Programming › How to redo the same code using structs › Re: Re: How to redo the same code using structs
July 27, 2009 at 5:34 pm
#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:
1 2 3 | <br /> void addStudent (char name[SIZE][LENGTH], int id[SIZE], int crn[SIZE][4]);<br /> |
change it to:
1 2 3 | <br /> void addStudent ( STUDENT newStudent );<br /> |
when you need to access a member of the struct , just use the dot operator and use the data as usual:
1 2 3 4 5 | <br /> ..........<br /> printf ( newStudent.name ); //output the student name<br /> printf ( "%i" , newStudent.id ); //output the student id<br /> |
not too much to the conversion …….