6.18.37 remove Function

Deletes the specified file.

Attention: This function is not implemented by MPLAB XC8.

Include

<stdio.h>

Prototype

int remove(const char * filename);

Argument

filename
name of file to be deleted

Return Value

Returns 0 if successful; otherwise, returns -1.

Remarks

If the file represented by filename does not exist or is open, remove will fail.

Example

#include <stdio.h>

int main(void)
{
  if (remove("myfile.txt") != 0)
    printf("Cannot remove file");
  else
    printf("File removed");
}

Example Output

File removed