Demonstrates the remove() function. - C File

C examples for File:File Operation

Description

Demonstrates the remove() function.

Demo Code

#include <stdio.h>

int main( void )
{
    char filename[80];

    printf("Enter the filename to delete: ");
    gets_s(filename);//from   w w w  .j ava2 s  .  c om

    if ( remove(filename) == 0)
        printf("The file %s has been deleted.\n", filename);
    else
        fprintf(stderr, "Error deleting the file %s.\n", filename);
    return 0;
}

Result


Related Tutorials