RAD Studio
ContentsIndex
PreviousUpNext
remove, _wremove

Header File 

stdio.h  

Category 

Input/output Routines 

Prototype 

int remove(const char *filename); 

int _wremove(const wchar_t *filename); 

Description 

Removes a file. 

remove deletes the file specified by filename. It is a macro that simply translates its call to a call to unlink. If your file is open, be sure to close it before removing it. 

The filename string can include a full path. 

Return Value 

On successful completion, remove returns 0. On error, it returns -1, and the global variable errno is set to one of the following values:

EACCES 
Permission denied 
ENOENT 
No such file or directory 

Example

#include <stdio.h>
int main(void)
{
    char file[80];
    /* prompt for file name to delete */
    printf("File to delete: ");
    gets(file);
    /* delete the file */
    if (remove(file) == 0)
       printf("Removed %s.\n",file);
    else
       perror("remove");
    return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
remove 
_wremove 
 
NT only 
 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!