How about this :-
std::ifstream inFile("file");
std::count(std::istreambuf_iterator<char>(inFile),
std::istreambuf_iterator<char>(), '\n');
More Related Contents:
- mmap() vs. reading blocks
- Getting a FILE* from a std::fstream
- How to write a large buffer into a binary file in C++, fast?
- Fast textfile reading in c++
- C++ ifstream failbit and badbit
- How to write to middle of a file in C++?
- fstream won’t create a file [duplicate]
- How can I use non-default delimiters when reading a text file with std::fstream?
- CLion C++ can’t read/open .txt file in project directory
- How to extract a multiline text segment between two delimiters under a certain heading from a text file using C++ [closed]
- How do I take values from text file and input into a 2D array? c++
- Do I need to manually close an ifstream?
- Using scanf() in C++ programs is faster than using cin?
- Non-blocking console input C++
- In C++ is there a way to go to a specific line in a text file?
- std::fstream doesn’t create file
- Elegant ways to count the frequency of words in a file
- What is the most elegant way to read a text file with c++?
- What is the Fastest Method for High Performance Sequential File I/O in C++?
- checking for eof in string::getline
- How to read a file into vector in C++?
- Reading and writing a std::vector into a file correctly
- Why is failbit set when eof is found on read?
- std::fstream buffering vs manual buffering (why 10x gain with manual buffering)?
- How to check if a file has been opened by another application in C++?
- Reading a file character by character in C
- Reading a Matrix txt file and storing as an array
- C++ ifstream error using string as opening file path.
- Performance Difference Between C and C++ Style File IO
- are “seekp” & “seekg” interchangeable?