Answers for "c++ get file content"

C++
0

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

Browse Popular Code Answers by Language