Results 1 to 4 of 4

Thread: C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Nov:2005
    Location: Sofia
    Posts: 118

    C++

    (10 ) ( ) .
    Code:
    #include <iostream.h>
    #include <conio.h>
    #include <fstream.h>
    #include <dos.h>
    #include <stdlib.h>
    #include <string.h>
    
    
    #define NAME "slujitel.dat"
    
    struct slujitel{ char ime[15];
                     char prezime[15];
                     char familiq[15];
                     char egn[10];
                     int  kod; };
     void vavejdane();
     void izvejdane();
     void tyrsene();
     void iztrivane();
     
     fstream f;
     
     void main()
     { int menu;
       for ( ; ; )
       {  cout<<endl<<"     Menu";
          cout<<endl<<"   1.Vavejdane na danni.";
          cout<<endl<<"   2.Izvejdane na vsichki danni.";
          cout<<endl<<"   3.Tyrsene na zapis po EGN.";
          cout<<endl<<"   4.Iztrivane na dannite.";
          cout<<endl<<"   5.Izhod ot programata.";
          cout<<endl;
          cout<<endl<<" Vashiqt izbor e : ";
          cin>>menu;
          if ( menu>0 || menu<6 )
           { switch (menu)
       { case 1: vavejdane(); break;
         case 2: izvejdane(); break;
         case 3: tyrsene(); break;
         case 4: iztrivane(); break; 
         case 5: cout<<endl<<endl<<"  Izlizane ot programata"; exit(0); } } } }
    
     void vavejdane()
      { slujitel sl;
        cout<<endl<<"  Vyvedete slednite danni na slijitelq: ";
        cout<<endl<<endl<<"    Ime: ";
        cin>>sl.ime;
        cout<<endl<<"    Prezime: ";
        cin>>sl.prezime;
        cout<<endl<<"    Familiq: ";
        cin>>sl.familiq;
        cout<<endl<<"    EGN: ";
        cin>>sl.egn;
        cout<<endl<<"    Kod na zaemanata dlyjnost: ";
        cin>>sl.kod;
        cout<<endl<<endl<<"  Dannite sa vyvedeni.";
        f.open(NAME,ios::app);
        f.write((char*)&sl,sizeof(slujitel));
        f.close(); }
    
     void izvejdane()
      { long int n;
        slujitel sl;
        f.open(NAME, ios::in);
        f.seekg(0,ios::end);
        n=f.tellg()/sizeof(slujitel);
        f.close();
        if ( n==0 ) cout<<" Nqma zapisi vyv fila.";
        else{ f.open(NAME, ios::in);
              for (int i=0; i<n; i++)
                { f.read((char*)&sl,sizeof(slujitel));
                  cout<<endl<<sl.ime;
                  cout<<endl<<sl.prezime;
                  cout<<endl<<sl.familiq;
                  cout<<endl<<sl.egn;
                  cout<<endl<<sl.kod<<endl<<endl; }
               f.close(); } }
    
    void tyrsene()
      { slujitel sl;
        char egn[10];
        long int n;
        int br=0;
        cout<<" Vavedete EGN-to na tyrseniqt slujitel: ";
        cin>>egn;
        f.open(NAME, ios::in);
        f.seekg(0,ios::end);
        n=f.tellg()/sizeof(slujitel);
        f.close();
        f.open(NAME, ios::in);
        for (int i=0; i<n; i++) 
         { f.read((char*)&sl,sizeof(slujitel));
           if (strcmp(sl.egn,egn)==0)
             { cout<<endl<<sl.ime;
               cout<<endl<<sl.prezime;
               cout<<endl<<sl.familiq;
               cout<<endl<<sl.egn;
               cout<<endl<<sl.kod<<endl;
               br++;  } }
        f.close();
        if (br==0) cout<<endl<<" Nqma nameren slujitel"<<endl;  }
    
     void iztrivane()
      { f.open(NAME,ios::out);
        f.close();
        cout<<" Dannite sa iztriti."; }

  2. #2
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    .

    - . .

    , <ctype.h> , isalpha() .
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  3. #3
    Registered User
    Join Date: Nov:2005
    Location: Sofia
    Posts: 118
    Quote Originally Posted by anrieff View Post
    .

    - . .

    , <ctype.h> , isalpha() .
    , 10 , -, 10.

  4. #4
    Registered User mitkohr's Avatar
    Join Date: Jul:2001
    Posts: 1,361
    :
    Code:
    if(strlen(sl.egn) == 10) {
    ....
    }
    Gigabyte X570 Aorus Elite, AMD Ryzen 7 5800X@PBO+200, Noctua NH-D15, 2x16GB G.Skill F4-3600C17D-32GTZR, Palit GeForce RTX 4070 Ti GameRock Classic, 2x Sandisk Extreme II 240GB (not in RAID)+WD 320GB AAKS + WD40EZRZ + Toshiba X300 6GB, Cooler Master HAF 922, CORSAIR 750W CX

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |