Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. struct Ziemniak{
  11.  
  12. string rodzaj;
  13. float dzien;
  14. float miesiac;
  15.  
  16. };
  17.  
  18. Ziemniak batat;
  19.  
  20. cout << "Podaj nazwe, oraz dzien i miesiac zakupu: " << endl;
  21. cin >> batat.rodzaj;
  22. cin >> batat.dzien;
  23. cin >> batat.miesiac;
  24.  
  25. fstream plik;
  26.  
  27. plik.open("Struktura.txt", ios::app | ios::in);
  28.  
  29. plik << batat.rodzaj << " " << batat.dzien << " " << batat.miesiac << endl;
  30. cout << "------------------------------------------";
  31. cout << "\n \n";
  32.  
  33. plik.close();
  34.  
  35. plik.open("Struktura.txt");
  36.  
  37. string g;
  38.  
  39. for(int i = 0; i <= 2; i++)
  40. {
  41.  
  42. plik >> g;
  43. cout << g << " ";
  44. }
  45.  
  46. plik.close();
  47.  
  48.  
  49.  
  50.  
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement