DEV Community

Coral Kashri
Coral Kashri

Posted on

Reading Text Files Like a Pro - C++

Are you tired of the old way of reading text files in C++? Have you always dreamed about reading them in Python-like fashion? Now you can. Enjoy.

for (std::string_view line : file_reader<'\n'>(file)) {
   std::cout << line << "\n";
}
Enter fullscreen mode Exit fullscreen mode

Using std::istream_iterator and a delimiter hack, we can enjoy the new world of C++.

See the full header in my repo: https://github.com/coralkashri/simple_file_reader_cpp ad if you like it, you can always give it your star ✨

Top comments (0)