c_-_c_files:read_file_into_string
Table of Contents
C - C++ Files - Read file into string
read_file_into_string.hpp
#pragma once #include <string> std::wstring read_file_into_wstring(std::string filename); std::string read_file_into_string(std::string filename);
read_file_into_string.cpp
#include "read_file_into_string.hpp" #include <sstream> #include <fstream> std::wstring read_file_into_wstring(std::string filename) { std::wostringstream stream; stream << std::wifstream(filename).rdbuf(); return stream.str(); } std::string read_file_into_string(std::string filename) { std::ostringstream stream; stream << std::ifstream(filename).rdbuf(); return stream.str(); }
References
c_-_c_files/read_file_into_string.txt · Last modified: 2021/04/28 09:21 by peter