struct studentInfo
{
int highestGrade;
int highestGradeLocation;
int lowestGrade;
int lowestGradeLocation;
int averageScore;
};
void Grades(studentInfo) {}
int main()
{
// first create a variable
studentInfo v1;
// then access its members
v1.highestGrade = 99;
// or you can set every member right away
studentInfo v2 = {99, 10, 10, 4, 12};
Grades(v2); // calling a function
}
Structs, when passed to functions, should be passed by reference. To see why, run this code demo. You will notice that the struct (if not passed by reference) will not be properly modified by the function calling to use it.
When you run this code you will notice that only two of the variables are changed.