Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "iostream"
- #include "fstream"
- #include "string"
- #include "sstream"
- #include "stdlib.h"
- #include "conio.h"
- using namespace std;
- struct Spetent
- {
- int numer;
- int pin;
- float kwota;
- };
- class BAZA
- {
- public:
- Spetent petent[20];
- BAZA()
- {
- for(int i = 0; i<20; i++ )
- {
- petent[i].numer = 0;
- petent[i].pin = 0;
- petent[i].kwota = 0;
- }
- }
- void Pobierz()
- {
- ifstream pobierz("dane.txt");
- string linia;
- int spacja = 0;
- int index = 0;
- while(getline(pobierz,linia))
- {
- for(int i = 0; i < 20; i++)
- {
- string bufor("");
- if(linia[i] == ' ') ++i;
- while(linia[i] != ' ')
- {
- bufor += linia[i];
- if(i+1 == linia.size()) break;
- else if(linia[i+1] == ' ') break;
- ++i;
- }
- stringstream temp; temp.clear();
- temp << bufor;
- if(spacja == 0) temp >> petent[index].numer;
- if(spacja == 1) temp >> petent[index].pin;
- if(spacja == 2) temp >> petent[index].kwota;
- ++spacja;
- if(spacja == 3)
- {
- spacja = 0;
- index++;
- }
- }
- }
- }
- void zapisz()
- {
- ofstream zapisz("danee.txt");
- for(int i = 0; i < 20; i++)
- {
- zapisz << petent[i].numer << " " << petent[i].pin << " " << petent[i].kwota << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment