Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.    /* fstream f;
  8.     f.open("plik.txt",ios_base::in);
  9.  
  10.     string s;
  11.     int i;
  12.  
  13.  
  14.  
  15.  
  16.     f.open("plik.txt", ios_base::app);
  17.  
  18.     f << "ola" << " " << 17 << endl;
  19.     f << "jola" << " " << 17 << endl;
  20.     f << "tola" << " " << 17 << endl;
  21.     f << "olaf" << " " << 17 << endl;
  22.     f << "pola" << " " << 17 << endl;
  23.     f << "julia" << " " << 17 << endl;
  24.  
  25.     f.close();
  26.  
  27.     f.open("plik.txt", ios_base::out);
  28.  
  29.     for(int i=1; i<=10; i++)
  30.     {
  31.         f<<i<<" ";
  32.         for(int j=1; j<=10; j++)
  33.         {
  34.             f<<i*j<<" ";
  35.  
  36.         }
  37.         f<<endl;
  38.     }
  39.     f.close();
  40.     for(int i=1; i<=10; i++)
  41.     {
  42.         f>>s;
  43.         cout<<s;
  44.         for(int j=1; j<=10; j++)
  45.         {
  46.             f>>s;
  47.             cout<<s;
  48.             f>>i;
  49.             cout<<i;
  50.         }
  51.         cout<<endl;
  52.     }
  53.     char c[20];
  54.     fstream fo;
  55.     fo.open("plik.txt", ios_base::out);
  56.     fo<<"ala"<<endl;
  57.     fo<<"ola"<<endl;
  58.     fo<<"tola"<<endl;
  59.     fo.close();
  60.     fo.open("plik.txt", ios_base::app | ios::out);
  61.     fo<<"ala"<<endl;
  62.     fo<<"ola"<<endl;
  63.     fo<<"brunhilda"<<endl;*/
  64.     fstream p;
  65.     p.open("plik.txt", ios_base::in);
  66.  
  67.     char imie[24], nazwisko[24], miejscowosc[24];
  68.     while(!p.eof())
  69.     {
  70.         p.get(imie, ',');
  71.         cout<<imie<<" ";
  72.         p>>nazwisko;
  73.         cout<<nazwisko<<" ";
  74.         p.getline(miejscowosc, 1024);
  75.         cout<<miejscowosc<<endl;
  76.     }
  77.  
  78.  
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement