I would like to get an istream_iterator-style iterator that returns each line of the file as a string rather than each word. Is this possible?
The standard library does not provide iterators to do this (although you can implement something like that on your own), but you can simply use the getline function (not the istream method) to read a whole line from an input stream to a C++ string.
Example:
#include
#include
#include
#include
using namespace std;
int main()
{
ifstream is("test.txt");
string str;
while(getline(is, str))
{
cout<