The task is as follows. It is necessary with the help of the structure to enter the name of the students, year of birth, year of entering the university and assessment of exams. Bring out students whose last name begins with the letter A and their grades.

#include <stdio.h> #include <string.h> #include <conio.h> struct famA { char fio[100]; int yearbirth, yearpost; int matan, rus, op; } round[3]; int main() { int i; puts("Vvedite dannye o studentah"); for (i = 0; i < 3; i++) { puts("FIO: "); gets(round[i].fio); printf("\nYear of birth: "); scanf_s("%i", &round[i].yearbirth); printf("\nYear of post: "); scanf_s("%i", &round[i].yearpost); printf("\nGrade matan: "); scanf_s("%i", &round[i].matan); printf("\nGrade rus: "); scanf_s("%i", &round[i].rus); printf("\nGrade OP: "); scanf_s("%i", &round[i].op); } //ввод данных о студентах for (i = 0; i < 3; i++) { if (round[i].fio[0] == 'A') { puts(round[i].fio); printf("\nmatan = %i \nrus = %i OP = %i", round[i].fio, round[i].matan, round[i].rus, round[i].op); } } _getch(); } 

Everything is OK with me, except for one thing - the full name can be entered only once (the first one), and then he writes "FIO:", but does not give input, switches right to the year of birth. FIO:

Wednesday VS 2015.

  • and flushall () tried or something similar? - pavel
  • @pavel tried, all the same: ( - Nazariy
  • if you flush exactly before reading the last name, then try after scanf_s ("% i", & round [i] .op); read the line gets. But this is a crutch. - pavel
  • And if it gets replaced with an honest scanf_s ? - VladD
  • @pavel Yes, the flushall + scanf_s + gets combination produces the desired result. Only now I wonder why. It now remains to find out why it displays only the last last name, starting with the letter A. - Nazariy

0