daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Mar 21st, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. string imie,nazwisko;
  8. int nr_telefonu;
  9.  
  10. int main()
  11. {
  12.  
  13.  
  14.   fstream plik;
  15.   plik.open("wizytowka.txt",ios::out | ios::app);
  16.  
  17.     if(plik.good()==false)
  18.     {
  19.         cout<<"Plik nie istnieje!";
  20.         exit(0);
  21.     }
  22.     string linia;
  23.    int nr_linii=1;
  24.  
  25.     while (getline(plik,linia))
  26.     {
  27.         switch(nr_linii)
  28.         {
  29.             case 1: imie = linia; break;
  30.             case 2: nazwisko = linia; break;
  31.             case 3: nr_telefonu=atoi(linia.c_str()); break;
  32.  
  33.  
  34.         }
  35.         nr_linii++;
  36.     }
  37.  
  38.  
  39.  
  40.    plik.close();
  41.  
  42.      cout<<imie<<endl;
  43.   cout<<nazwisko<<endl;
  44.   cout<<nr_telefonu<<endl;
  45.  
  46.     return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top