Write a program in C to remove a file from the disk

Previous
Next

remove():

  • It used to rename the specified file.
  • Prototype is:
    • int  remove(char* target);
    • On success, it returns 0
    • On failure, it returns -1
#include<stdio.h>
int main()
{
	char target[20] = "data.txt";
	
	if(remove(target)==0)
		printf("successfully removed...\n");
	else
		printf("Failed in removing the file...\n");
	return 0;
}
Previous
Next

Courses Enquiry Form