remove

Description

Deletes a file.

#include <stdio.h> Required for ANSI compatibility  
#include <io.h> Use either IO.H or STDIO.H  

int remove( const char *path );

path Path name of file to be removed  

Remarks

The remove function deletes the file specified by path.

Return Value

The function returns 0 if the file is successfully deleted. Otherwise, it returns –1 and sets errno to one of these values:

Value Meaning

EACCES Path name specifies a read-only file.
ENOENT File or path name not found, or path name specifies a directory.

Compatibility

Standards:ANSI

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

See Also

_unlink

Example

/* REMOVE.C: This program uses remove to delete REMOVE.OBJ. */

#include <stdio.h>

void main( void )

{

if( remove( “remove.obj” ) == -1 )

perror( “Could not delete 'REMOVE.OBJ'” );

else

printf( “Deleted 'REMOVE.OBJ'\n” );

}

Output

Deleted 'REMOVE.OBJ'