Mega Code Archive

 
Categories / C++ / File
 

Put( ) to write all characters from zero to 255 to a file called CHARS

#include <iostream> #include <fstream> using namespace std;     int main() {   int i;   ofstream out("CHARS", ios::out | ios::binary);       if(!out) {     cout << "Cannot open output file.\n";     return 1;   }       // write all characters to disk   for(i=0; i<256; i++) out.put((char) i);       out.close();   return 0; }