Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <conio.h>
- using namespace std;
- struct Vlogove{
- string ime;
- string familiq;
- string egn;
- double vlog_v_leva;
- double vlog_v_evro;
- };
- void vuvejdane_na_vlogove(Vlogove [], int &);
- void tursene_po_ime_i_familiq(Vlogove[], int &);
- int main() {
- int n;
- Vlogove vlog[25];
- vuvejdane_na_vlogove(vlog, n);
- tursene_po_ime_i_familiq(vlog, n);
- return 0;
- }
- void vuvejdane_na_vlogove(Vlogove vlog[], int &n) {
- fstream file;
- file.open("vlogove.dat", ios::binary | ios::out);
- cout << "Vuvedi broi na vlogovete: ";
- cin >> n;
- for (int i = 0; i < n; i++) {
- cout << "Vuvedi ime: ";
- cin >> vlog[i].ime;
- cout << "Vuvedi familiq: ";
- cin >> vlog[i].familiq;
- cout << "Vuvedi egn: ";
- cin >> vlog[i].egn;
- cout << "Vuvedi vlog v leva: ";
- cin >> vlog[i].vlog_v_leva;
- cout << "Vuvedi vlog v evro: ";
- cin >> vlog[i].vlog_v_evro;
- }
- file.write( (char *) (&vlog), n * sizeof(vlog) );
- file.close();
- }
- void tursene_po_ime_i_familiq(Vlogove vlog[], int &n) {
- fstream file;
- string ime;
- string familiq;
- file.open("vlogove.dat", ios::binary | ios::out);
- file.read( (char *) (&vlog), n * sizeof(vlog) );
- cout << "Vuvedi ime po koeto da tursish: ";
- cin >> ime;
- cout << "Vuvedi familiq za imeto: ";
- cin >> familiq;
- for (int i = 0; i < n; i++) {
- if (strcmp( ime.c_str(), vlog[i].ime.c_str() ) == 0 && strcmp( familiq.c_str(), vlog[i].familiq.c_str() ) == 0 ) {
- cout << "Ime: " << vlog[i].ime << endl;
- cout << "Familiq: " << vlog[i].familiq << endl;
- cout << "EGN: " << vlog[i].egn << endl;
- cout << "Vlog v leva: " << vlog[i].vlog_v_leva << endl;
- cout << "Vlog v evro: " << vlog[i].vlog_v_evro << endl;
- }
- }
- file.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement