Advertisement
irmantas_radavicius

Untitled

Feb 20th, 2024
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8.  
  9.     cout << "Iveskite duomenu failo varda: ";
  10.     string vardas;
  11.     cin >> vardas;
  12.  
  13.     fstream in(vardas, fstream::in);
  14.     int kiek = 0;
  15.     if(in.is_open()){
  16.         string line;
  17.         //in >> line;
  18.  
  19.         while(1){
  20.             getline(in, line);
  21.             //cout << in.good() << in.bad() << in.fail() << in.eof() << " ";
  22.             if(in.fail())
  23.                 break;
  24.             kiek++;
  25.             //cout << line << endl;
  26.         }
  27.         in.close();
  28.         cout << "Faile yra " << kiek << " eiluciu" << endl;
  29.  
  30.     } else {
  31.         cout << "Nepavyko atidaryti failo." << endl;
  32.     }
  33.  
  34.  
  35.     return 0;
  36.  
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement