#include <stdio.h>
#include <stdlib.h>
struct subject
{
    int sub_code;
    char sub_name[20];
};
struct student
{
    char name[50];
    int id;
    struct subject etec;
};
void main()
{
    struct student s[3] = { NULL };
    int count;
    for (count = 0; count < 3; count++)
    {
        printf("****************STUDENT-%i*******************\n", (count + 1));
        printf("Enter name of student - ");
        gets_s(s[count].name);
        printf("Enter student id - ");
        scanf_s("%i", &s[count].id);
        printf("Enter subject code: ");
        scanf_s("%i", &s[count].etec.sub_code);
        printf("Enter subject name: ");
        gets_s(s[count].etec.sub_name); //ask for name of course
        system("cls");
    }
    for (count = 0; count < 3; count++)
    {
        printf("****************STUDENT-%i*******************\n", (count + 1));
        printf("Enter name of student - %s\n", s[count].name);
        printf("Enter student id - %i\n", s[count].id);
        printf("Enter subject code: %i\n", s[count].etec.sub_code);
        printf("Enter subject name: %s\n", s[count].etec.sub_name);
        puts("");
    }
    system("pause");
}
The following program when executed does not ask input for
gets_s(s[count].etec.sub_name);
Please tell how to correct this situation so that code asks me for all inputs. Also tell which one is better
scanf_s() or gets_s() for strings in c programming.
 
    