Read the whole file

... text file

std::string path="whatever";
 
std::ifstream f( path );
if( !f.is_open() )
 throw std::runtime_error("oops...");

std::stringstream st;
st << f.rdbuf();

// the result is in 'txt'
std::string txt( st.str() );

No comments:

Post a Comment