Answers for "read all the contents of a file in c++"

C++
2

c++ get file content

#include <fstream>
#include <string>

int main(int argc, char** argv)
{

  std::ifstream ifs("myfile.txt");
  std::string content( (std::istreambuf_iterator<char>(ifs) ),
                       (std::istreambuf_iterator<char>()    ) );

  return 0;
}
Posted by: Guest on August-01-2021

Code answers related to "read all the contents of a file in c++"

Browse Popular Code Answers by Language