_unlink

Description

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  

Remarks

The _unlink function deletes the file specified by filename.

Return Value

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

Compatibility

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.

See Also

_close, remove

Example

/* 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” );

}

Output

Deleted 'UNLINK.OBJ'