Reading a file to a string in C++ -


As someone who is new to C ++ and coming from the background of Python, I Trying to translate to ++

  f = open ('transit_test.py') s = f.read ()  

something like that What is the least C ++ idioms to do?

The C ++ STL method of doing this is:

  #include & lt; String & gt; # Include & lt; Iterator & gt; # Include & lt; Fstream & gt; using namespace std; Wifstream f (L "transit_test.py"); Wstring s (istreambuf_iterator & lt; wchar_t & gt; (f), (istreambuf_iterator & lt; wchar_t & gt; ()));  

Comments