"Dave" <> wrote in message news:<>...
> Hello all,
>
> The scheme shown below to move a text file's contents into a std::string
> works with one exception: it drops the carriage return and line feed
> characters. How may I, in a Standard-compliant way, read in a text file's
> contents and keep the carriage returns and line feeds?
int main()
{
std::string file_contents;
std::ifstream file_stream("test_1.txt");
std:

stringstream temp;
temp << file_stream.rdbuf();
file_contents = temp.str();
std::cout << file_contents << std::endl;
return 0;
}
This also has the bonus that it's usually quite a bit faster.
--
Later,
Jerry.
The universe is a figment of its own imagination.