Any errors in the code, the search function simply displays the last person on the list, but should display the blond with the maximum height. Where are the mistakes? Thanks in advance for any help.
#include <conio.h> #include <iomanip> #include <iostream> #include <string> using namespace std; struct student { string fam, cvet; float rost, ves; }; short fMenu (); void fwriteinfile (char *file_name, student *pstud); void fvvod (student *pstud); void fpoisk(student *pstud); void freadfromfile (char *file_name); int n = 6; int main() { short choise; int count=0; char *fName = "D:\\student3.txt"; student *stud = new student[n]; do { cout<< "Studentov v spiske - "<< count << "/" << n <<endl; choise = fMenu(); switch (choise) { case 1: system("cls"); fwriteinfile(fName, stud); count++; _getch(); system("cls"); break; case 2: system("cls"); freadfromfile(fName); _getch(); system("cls"); break; case 3: system("cls"); fpoisk(stud); _getch(); system("cls"); break; case 0: cout << "Do svidaniya!!!" << endl; system ("pause"); break; default: cout << "Oshibka vvoda!!!" << endl; cout << "\n\nPress Enter..." << endl; _getch(); system("cls"); break; } } while(choise); cout << endl; return 0; } short fMenu () { short ch; cout << "|--------------------- MENU ----------------------------------------------|\n"; cout << "| [1] Vvod |" << endl; cout << "| [2] Vivod |" << endl; cout << "| [3] Poisk |" << endl; cout << "| [0] Vihod |" << endl; cout << "|-------------------------------------------------------------------------|\n"; cout << "Vash vibor: "; cin >> ch; return ch; } void fvvod (student *pstud) { cin.ignore(); cout <<"Vvedite informaciyu o studentah"<<endl; cout << "Familiya: "; getline(cin, pstud->fam); cout << "Rost: "; cin >> pstud->rost; cout << "Ves: "; cin >> pstud->ves; cout << "Cvet volos: "; cin >> pstud->cvet; cout<<endl; } void fwriteinfile (char *file_name, student *pstud) { fvvod(pstud); FILE *pfile = fopen(file_name,"ab"); cout<<" ЦДДДТДДДДДДДДДДДДТДДДДДДТДДДДДТДДДДДДДДДДДДДДД·"<<endl; cout<<" є N є Familiya є Rost є Ves є Cvet volos є"<<endl; cout<<" ЗДДДЧДДДДДДДДДДДДЧДДДДДДЧДДДДДЧДДДДДДДДДДДДДДД¶"<<endl; cout<<" є " " є"<<setw(10)<<pstud->fam<<" є"<<setw(7)<<fixed<<setprecision(2)<< pstud->rost<<" є"<<setw(7)<<pstud->ves; cout<<" є"<<setw(15)<<pstud->cvet<<" є"<<endl; cout<<" УДДДРДДДДДДДДДДДДРДДДДДДДРДДДДДРДДДДДДДДДДДДДДДЅ"<<endl; system("pause"); fwrite(pstud, sizeof(student), 1, pfile); cout << "Dannie v fail zapisani"; fclose(pfile); } void fpoisk (student *pstud) { char s[] = "blondin*"; int r=0; bool f=true; for (int i=1; i<=n; i++) { if (pstud->rost>r) { r=pstud->rost; } } cout<<endl<<endl<<endl; if (s==pstud->cvet && r==pstud->rost); { cout<<" Familiya: "<<pstud->fam<<endl; cout<<" Rost: "<<pstud->rost<<endl; cout<<" Ves: "<<pstud->ves<<endl; cout<<" Cvet volos: "<<pstud->cvet<<endl; f=false; } system("pause"); } void freadfromfile (char *file_name) { student *stud = new student[n]; int i=1; FILE *pFile = fopen(file_name,"rb"); cout << "Informatsiya o studentah: " << endl; while(!feof(pFile)){ fread(stud, sizeof(student), 1, pFile); if (!feof(pFile)){ cout <<i<< ": " << endl; cout << "Familiya: " << stud->fam << endl; cout << "Rost: " << stud->rost << endl; cout << "Ves: " << stud->ves << endl; cout << "Cvet volos: "<< stud->cvet<<endl; system ("pause"); i++; } } fclose(pFile); delete[] stud; }