Showing below is my program which takes 3 student information " id, name, and marks", in the first loop its run as expect, all variables were in order, but in the 2nd loop (and so on), the program keeps skip the gets(e[i].stname)
. It just prints the question about student name then jump direct to ask their 1st mark. I tried using debug but my experiences didn't help much.
#include<stdio.h>
struct stud
{
int stno;
char stname[20];
int stmark[3];
};
void main()
{
int n, m, i;
struct stud e[3];
for ( i = 0; i < 3; i++)
{
printf("enter the name of number %d student: \n", i+1);
gets(e[i].stname);
printf("enter the number of student number %d:\n", i+1);
scanf_s("%d", &e[i].stno);
for ( m = 1; m < 4; m++)
{
printf("enter the mark of module %d \n",m);
scanf_s("%d", &e[i].stmark[m-1]);
}
}
}