C++ examples for File Stream:stream
Using ofstream to Open a text File and Write to It
#include <iostream> #include <fstream> using namespace std; int main() /*from w w w .j a v a 2 s.c o m*/ { ofstream outfile("outfile.txt"); outfile << "I'm in a file!" << endl; int x = 200; outfile << x << endl; outfile.close(); return 0; }