Closes a file using system call 0x3E.
#include <dos.h> | ||
#include <errno.h> |
unsigned _dos_close( int handle );
handle | Target file handle |
The _dos_close function uses system call 0x3E to close the file indicated by handle. The file's handle argument is returned by the call that created or last opened the file.
The function returns 0 if successful. Otherwise, it returns the DOS error code and sets errno to EBADF, indicating an invalid file handle.
Do not use the DOS interface I/O routines with the console, low-level, or stream I/O routines.
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
_close, _creat, _dos_creat functions, _dos_open, _dos_read, _dos_write, _dup, _open
/* DOPEN.C: This program uses DOS I/O functions to open and close a file. */
#include <fcntl.h>
#include <stdio.h>
#include <dos.h>
void main( void )
{
int fh;
/* Open file with _dos_open function */
if( _dos_open( “data1", _O_RDONLY, &fh ) != 0 )
perror( ”Open failed on input file\n" );
else
printf( “Open succeeded on input file\n” );
/* Close file with _dos_close function */
if( _dos_close( fh ) != 0 )
perror( “Close failed\n” );
else
printf( “File successfully closed\n” );
}
Open succeeded on input file
File successfully closed