C++ examples for File Stream:stream
Save characters to file
#include <fstream> #include <iostream> #include <string> using namespace std; int main()/*from ww w. j av a 2 s . co m*/ { string str = "this is a test test test"; ofstream outfile("TEST.TXT"); //create file for output for(int j=0; j<str.size(); j++) //for each character, outfile.put( str[j] ); //write it to file cout << "File written\n"; return 0; }