0
I want to ask this question: what can i do(code langage c) to remove a file when i create it with fopen. I want to use remove .
Remove file langage c
1 Answer
+ 1
Something like this:
//----
const char *file_name = "file.txt";
FILE *f = fopen(file_name, "w");
// work with file......
fclose(f);
if(!remove(file_name)){
printf("file removed successfully\n");
}else{
printf("can't remove file\n");
perror("error: ");
}
//------