Advertisement
PiotrJurek

Zad7

May 30th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string imie = "Piotr";
  9.     string nazwisko = "Jurek";
  10.     string wiek = "18 lat";
  11.     string tekst;
  12.     ofstream zapis("plik.txt");
  13.     ifstream odczyt("plik.txt");
  14.  
  15.     if(zapis.is_open() && odczyt.is_open())
  16.     {
  17.         zapis << imie << " " << nazwisko << " " << wiek << endl;
  18.         odczyt.seekg(imie.length(),ios::beg);
  19.         getline(odczyt, tekst);
  20.         cout << tekst;
  21.     }
  22.     else
  23.     {
  24.         cout << "Blad odczytu pliku.";
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement