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/clibexam/fdopen.c

23 lines
367 B
C

#include <stdio.h>
#include <fcntl.h>
#include <io.h>
void main()
{
int handle;
FILE *fp;
handle = open( "file", O_RDONLY | O_TEXT );
if( handle != -1 ) {
fp = fdopen( handle, "r" );
if( fp != NULL ) {
/*
process the stream
*/
fclose( fp );
} else {
close( handle );
}
}
}