0
I would like to know why my programme does not accept reading the name of the second and third students at all. I’ve already used the buffer clean command, which is fflush(stdin) and he hasn’t done the same. Keep ignoring the name and reading only the code and the student’s 3 notes.
struct alunos a[3];
int i, j;
for (i = 0; i < 3; i++){
printf("Digite o nome do funcionario : ");
gets(a[i].nome);
fflush(stdin);
printf("Digite o codigo do aluno : ");
scanf("%d",&a[i].codigo);
for (j = 0; j < 3; j++){
printf("Digite a %d nota : ",j+1);
scanf("%f",&a[i].notas[j]);
}
printf("\n");
}
Since you are using
fflush(stdin);
, whose behavior is undefined and does not work in all environments, try to put before thegets(a[i].nome);
.– anonimo
Thanks, I had tested using the scanf command with fflush after and it worked. I realized now with your suggestion and it also worked!!
– Matheus Santos