This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/cplbexam/fstream/ofstream/handbuf.cpp

24 lines
603 B
C++
Raw Permalink Normal View History

#include <fstream.h>
#include <sys/types.h> //
#include <sys/stat.h> // C library
#include <fcntl.h> //
void main( void ) {
char s[20], *bp;
int handle, len = 20;
bp = new char[len];
handle = open( "temp.txt", O_WRONLY | O_CREAT | O_TEXT, S_IWUSR );
ofstream output ( handle, bp, len );
output << "Just for fun!" << endl;
ifstream input ( "temp.txt" );
cout << "The content of \"temp.txt\":" << endl;
while( (input >> s).good() ) {
cout << s << " " << flush;
}
delete bp;
}