C++ examples for File Stream:File Operation
Copy one file to another, a line at a time
#include <string> #include <fstream> using namespace std; int main() {/* www. j av a 2 s .c om*/ ifstream in("s.cpp"); // Open for reading ofstream out("t.cpp"); // Open for writing string s; while(getline(in, s)) // Discards newline char out << s << "\n"; // ... must add it back }