Advertisement
cd62131

countline

Apr 13th, 2014
1,419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5. int countline(ifstream& fin) {
  6.   int n = 0;
  7.   string line;
  8.   while(getline(fin, line)) n++;
  9.   return n;
  10. }
  11. int main(int argc, char **argv) {
  12.   ifstream fin(argv[1]);
  13.   cout << countline(fin) << endl;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement