Hello! The goal of the task below is: run the program, get the line
Enter information about students, last name (letters), faculty (numbers), year of birth (numbers)
You enter three students and then another line pops up.
Enter the desired student
Enter the name of any of the previously entered students and the program gives out everything about this student (faculty, year of birth). So, it is necessary that the faculty be introduced not in numbers, but in letters, like a surname. That is, so that the prog looked not like this
Last name: Bogotkov Faculty: 23 Year of birth: 1994
that's how
Surname: Bogotkov Faculty: Information Security Year of birth: 1994
I tried many options, the program either does not start at all, or is cut down after the first pressing of Enter. I would be very grateful if you help.
#include <string.h> #pragma hgrstop #pragma argsused #include <stdio.h> #include <conio.h> #include <iostream.h> #define n 3 int main() { int i,k; float sum; struct tov { char name[10]; float c; int kol; }t; /*struct*/ tov mag[3]; char nazv[10]; clrscr(); printf("\n vvedite informaciyu stydentov\n"); for (i=0;i<n;i++) { printf("\n familia, fuckyltet, god rojdeniya: "); scanf("%s%f%d",&t.name,&t.c,&t.kol); mag[i]=t; getch(); } printf("\n Vvedite iskomogo stydenta: "); scanf("%s",nazv); for(i=0,sum=0,k=0;i<n;i++) if(strcmp(mag[i].name,nazv)==0) { sum=mag[i].kol; getch(); k=mag[i].c; } printf("Familia: %s\t Fackyltet: %d\t God rojdeniya:%5.0f",nazv,k,sum); getch(); return 0; }