pcb@gator.cacs.usl.edu (Peter C. Bahrs) (03/15/90)
/********************************************/ #include <stream.h> extern int strlen(char *); class Demo { filebuf f; ostream *O; public: void OpenForWrite (char* fname); void Write (char* str); void Close (void); }; void Demo::OpenForWrite (char* fname) { if (!f.open(fname,output)) { cerr << "ERROR: Can't open file (" << fname << ")\n"; exit(1); } O = new ostream(&f); } void Demo::Write(char* str) { cout << str; (*O) << str; } void Demo::Close(void) { f.close(); } main() { Demo D; D.OpenForWrite("file1"); D.Write("here it is\n"); D.Close(); } /*----------- Thanks in advance... --------------------------------------+ | Peter C. Bahrs | | The USL-NASA Project | | Center For Advanced Computer Studies INET: pcb@gator.cacs.usl.edu | | 2 Rex Street | | University of Southwestern Louisiana ...!uunet!dalsqnt!gator!pcb | | Lafayette, LA 70504 | +-----------------------------------------------------------------------*/