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; } 

Closed due to the fact that off-topic participants Yura Ivanov , Mirdin , fori1ton , VenZell , PashaPash 6 May '15 at 7:56 .

  • Most likely, this question does not correspond to the subject of Stack Overflow in Russian, according to the rules described in the certificate .
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • @Nikitos, According to the rules of the forum, questions should not be limited to solving or completing the training tasks for students. - Nicolas Chabanovsky
  • four
    I vote for closing this issue as not relevant topic. Work for the author. - Yura Ivanov

1 answer 1

such things rushed into the eye: the structure is declared to OUTSIDE OTHER main (), secondly the delay function is written _getch (); dash in front is needed more shortly

you also have a name field array (name [10]) and in the code you are trying to enter the data as in a regular variable (t.name), you need an index

I am sure that besides this you still have a lot of jambs, but there is no compiler at hand, but I don’t remember very well as a memory

  • the program works fine, there are no errors in it, you just need to redo it (as mentioned above), I don’t know how. - Nikitka