Read the entire file in String

xiaoxiao2021-03-06  40

Infile >> STR does not continue to enter the return space.

I don't know that std :: noskipws does not play this role, even if it is not used, the GCC 2.95.2 used does not support NoskiPws.

-------------------------------------------------- ----------------------

Iostream famous expert Dietmar Kuehl gives two methods

Std :: ifstream in ("some.file");

Std :: istreambuf_iterator beg (in), end;

Std :: string str (beg, end);

or

#include

Std :: ifstream in ("some.file");

Std :: ostringstream TMP;

TMP << in.rdbuf ();

Std :: string str = tmp.str ();

转载请注明原文地址:https://www.9cbs.com/read-65855.html

New Post(0)