Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ read entire file into a variable

// Read Entire File Into a String Variable
// More Info: https://stackoverflow.com/a/116177/7573706
ifstream myFile("stuff.txt");
string str(std::istreambuf_iterator<char>{myFile}, {});

Requirements: 
#include <string>
#include <iostream>
#include <fstream>
#include <iterator>
 
PREVIOUS NEXT
Tagged: #read #entire #file #variable
ADD COMMENT
Topic
Name
6+6 =