C++ examples for File Stream:File Operation
Read an entire file into a single string
#include <string> #include <iostream> #include <fstream> using namespace std; int main() {/*from ww w. j a v a2 s .c o m*/ ifstream in("main.cpp"); string s, line; while(getline(in, line)) s += line + "\n"; cout << s; }