/** * student-experiments * Some experiments with students. */ // +---------+-------------------------------------------------------- // | Headers | // +---------+ #include "student.h" // Duh. #include // For printf, stdout, and such // +------+----------------------------------------------------------- // | Main | // +------+ int main () { // Set up a group of sample students. struct student *class[] = { student_new ("John", "Doe", "00001234", 3.4, 0), student_new ("John", "Ode", "10203040", 2.0, 100000), student_new ("Jane", "Doe", "00001233", 3.9, 1005000), student_new ("Jack", "Doe", "00112233", 3.2, 234012), student_new ("Jan", "Edo", "20199999", 2.7, 123450), student_new ("Sam", "Are", "20199998", 1.5, 50), student_new ("Sam", "IAm", "20199908", 3.5, 543210), student_new ("Jane", "IAm", "20199908", 3.5, 543210) }; int num_students = sizeof (class) / sizeof (struct student *); // Do something with them. (Say, sort them.) // Print them out. int i; for (i = 0; i < num_students; i++) { printf ("%2d: ", i); student_print (class[i], stdout); printf ("\n"); } // for each student // And we're done. return 0; } // main