The prototype of this function is given below.
int remove(const char* filename);
After the operation of the above function, the file is no longer accessible with the name given as the argument. The subsequent attempts to open the file with the same name will fail unless it is created again with that name.
Illustrates the functions remove()
#include <stdio.h> #include <stdlib.h> void main() { FILE* fptr ; fptr = fopen("Student file", "w"); clrscr(); if( fptr == NULL) //test if fopen () fails to open file. / { printf("File could not be opened."); exit (1); } else printf("File Student_file is open for writing.\n"); remove ("Student_file"); if(remove ("Student_file") != 0) // test for removal printf ("Student_file is removed. \n"); freopen ("Student_file", "a", fptr); /* reopen file for appending*/ if(fptr ==NULL) printf( "Failed to reopen"); printf ("Student_file is opened again. \n"); fclose (fptr); }