remove()

Declaration

int remove(const char* kcpFilePath);

Description:

This function deletes the file designated by the file path given by the string "kcpFilePath." If successful, the function deletes the file and returns 0. Otherwise, the function returns -1 and and sets the value of errno to indicate an error.

Example

#include <cstdio>

int main()
{
    // Delete the local file
    int iRet = remove("XoaX.txt");

    // Check whether or not some characters were written
    if (iRet == -1) {
        perror("Failed to remove file XoaX.txt");
    } else {
        printf("The file XoaX.txt was deleted.\n");
    }

    return 0;
}


Local Folder Before Run:





Local Folder After Run:



Output:

remove() Output