Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. std::ifstream inFile("file");
  2. std::count(std::istreambuf_iterator<char>(inFile),
  3. std::istreambuf_iterator<char>(), 'n');
  4.  
  5. int numLines = 0;
  6. ifstream in("file.txt");
  7. std::string unused;
  8. while ( std::getline(in, unused) )
  9. ++numLines;
  10.  
  11. int numLines = 0;
  12. ifstream in("file.txt");
  13. //while ( ! in.eof() )
  14. while ( in.good() )
  15. {
  16. std::string line;
  17. std::getline(in, line);
  18. ++numLines;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement