The problem is to find the greatest average of a group of students. As you know Structure works here and to my point of view it's a good idea (Or maybe) that first make that structure using Array of Structure because I have for example 30 students. Then searching through the members of that structure and find the ultimate answer.
But I've encountered a problem which I can't fill the struct Stdinfo student[stdnum] and my for loop actually doesn't work correctly and I don't know why!
As a check I used printf() to print one of the members but I couldn't.
Here is my code :
#include <stdio.h>
struct Stdinfo
{
    char name[30];
    int score;
};
struct Stdinfo function();
int main(int argc, char **argv)
{
    //Number of students ~stdnum
    int stdnum, i;
    puts("Input numbers of student(s) :");
    scanf("%i", &stdnum);
    stdnum--;
    struct Stdinfo student[stdnum];
    //Filling array of structure
    for (i = 0; i < stdnum; i++)
    {
        student[i] = function();
    }
    return 0;
}
struct Stdinfo function()
{
    struct Stdinfo student;
    puts("Input the name of the student : ");
    fgets(student.name, sizeof(student.name), stdin);
    puts("Input his(her) score:");
    scanf("%i", &student.score);
    return student;
}
Now searching is not my main problem and I appreciate any help by which I can solve "Structure's members filing" problem.
 
    