_dos_close
raw OCR
Closes a file.
Defined in header <dos.h>
Syntax
#include <dos.h>
unsigned _dos_close(int handle);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
_dos_close closes the file associated with handle, handle is a file handle obtained from a _dos_creat, _dos_creatnew, or _dos_open call.
Return value
Upon successful completion, _dos_close returns 0. Otherwise, it returns the DOS error code and the global variable errno is set to
EBADF Bad file number
See also
Example
#include <dos.h>
#include <string.h>
#include <stdio.h>
int main(void)
{
unsigned count;
int handle;
char buf[ll] = "0123456789";
/* create a file containing 10 bytes */
if (_dos_creat("DUMMY.FIL", _A_NORMAL, &handle) 0) {
perror("Unable to create DUMMY.FIL");
return 1;
if (_dos_write (handle, buf, strlen(buf), &count) != 0) {
perror("Unable to write to DUMMY.FIL");
return 1;
}
_dos_close(handle) /* close the file */
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `dos close` read as `_dos_close`
Stable link: /3.1/dos.h/_dos_close/
· short form /3.1/_dos_close/