I'am just starting with programming a code with structure. I need some input on the bottom four lines of codes., why wouldn't it read in the values. Seems to work fine, up to that point.
Code:#include <stdio.h> #define grade_test 3 struct graderecord { char name[21]; char id_num[12]; float test[grade_test]; float final; float homework; float total; }; void read_in_students(struct graderecord *std_ptr); int main(void) { struct graderecord grades; read_in_students(&grades); } void read_in_students(struct graderecord *std_ptr) { int i,j,num_students; printf("Number of students in class:"); scanf("%d",&num_students); /* Input information about students */ for (i = 0; i < num_students; i++) { printf("Enter student name #%d: ", i+1); scanf("%s", std_ptr->name); printf("Enter student id number: "); scanf("%d",std_ptr->id_num); for (j = 0; j < grade_test; j++) { printf("Enter score on test #%d: ", j+1); scanf("%f", std_ptr->test); } printf("Enter homework score; "); scanf("%f", &graderecord.homework); printf("Enter the final exam score: "); scanf("%f",&grade.final); } }



LinkBack URL
About LinkBacks


