Deletes a file.
#include <io.h> | Required only for function declarations | |
#include <stdio.h> | Use either IO.H or STDIO.H |
int _unlink( const char *filename );
filename | Name of file to remove |
The _unlink function deletes the file specified by filename.
If successful, _unlink returns 0; otherwise, it returns –1 and sets errno to one of the following constants:
Value | Meaning |
EACCES | Path name specifies a read-only file |
ENOENT | File or path name not found, or path name specified a directory |
Standards:UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
Use _unlink for compatibility with ANSI naming conventions of non-ANSI functions. Use unlink and link with OLDNAMES.LIB for UNIX compatibility.
_close, remove
/* UNLINK.C: This program uses _unlink to delete UNLINK.OBJ. */
#include <stdio.h>
void main( void )
{
if( _unlink( “_unlink.obj” ) == -1 )
perror( “Could not delete 'UNLINK.OBJ'” );
else
printf( “Deleted 'UNLINK.OBJ'\n” );
}
Deleted 'UNLINK.OBJ'