This is a program to enter the details like name and address of students and display them to understand functions and structures but faced a problem. The first gets of the input function is not working and taking any input. Where have I gone wrong and what can be done to make it work?
   #include <string.h>
   struct student
    {
        long int roll;
        char name[100];
        char address[100];
        int age;
        int avg_marks;
    }std[3];
    void input()
    {
        int i;
        for (i=0;i<3;i++)
        {
            printf("Enter the details of %dth student:\n",i+1);
            printf("ROLL NO.: ");
            scanf("%ld",&std[i].roll);
            printf("NAME: ");
            gets(std[i].name); //Not working//
            printf("ADDRESS: ");
            gets(std[i].address);
            printf("AGE: ");
            scanf("%d",&std[i].age);
            printf("AVERAGE MARKS: ");
            scanf("%d",&std[i].avg_marks);
            printf("\n");
        }
    }
    void print()
    {
        int i;
        for (i=0;i<3;i++)
        {
            printf("Details of %dth student:\n",i+1);
            printf("ROLL NO.: %ld\n",std[i].roll);
            printf("NAME: ");
            puts(std[i].name);
            printf("\nADDRESS: ");
            puts(std[i].address);
            printf("\nAGE: %d\n",std[i].age);
            printf("AVERAGE MARKS: %d",std[i].avg_marks);
            printf("\n");
       }
    } 
    void main()
    {
        void input();
        void print();
        input();
        print();
    }```
