Hi,
I'm working on a program to sort students by last name, first name, middle initial, gpa, etc. I've defined a data structure called "Student."
Code:
typedef struct
{
char last[21];
char first[11];
char mi;
double gpa;
}Student;
I wrote a function which will scan a line of a text file, then fill in each part of the "Student" data structure, and return a variable (type Student), called studentx.
Now, I need to declare an array of type "Student" and input "studentx" into each index, after it comes out of the function. Keep in mind every time I call the function, a different "studentx" will be returned.
My first problem is that I don't think I'm defining it right. I have this
Code:
struct Student studentList[1000];
but I get the error "studentrpt.c:32: error: array type has incomplete element type"
any ideas?
to input my "student" variable into the studentList array, here's what I have. (it says "i" because it's in a loop, but i'm not worried about the loop right now, so don't worry about it either. As stated, the "getInfo" function returns type Student.
Code:
studentList[i] = getInfo(input, student);
Now say I want to print a specific thing from a specific index of my studentList array, for example, I want to print the first name of the student in the 27th index of the array. How do I do that? What variable do i put in the printf statement?
is it this?
studentList[27].first
Any help is appreciated, thanks!