#include <iostream.h> #include <iomanip.h> #include <fstream.h> extern "C" { #include <time.h> #include <stdlib.h> } void main() { char buf[81]; ofstream out; srandom(time(NULL)); buf[80] = '\0'; out.open("test.dat", ios::out); if (!out) { cerr << ": Can't write to file" << endl; exit(1); } for (int i=0; i<23; i++) { for (int j=0; j<80; j++) { if (random() % 6 > 3) buf[j] = '#'; else buf[j] = ' '; } out << buf << '\n'; // out << buf << endl; } out << flush; out.close(); }
© 1997 Gottfried Rudorfer, C++-AG, Lehrveranstaltungen, Abteilung für Angewandte Informatik, Wirtschaftsuniversität Wien, 1/11/1999 |