given argument fd
in type of FILE*
, for example:
FILE* fd = fopen("a.txt","w")
.
How can I delete all the text that writed in a.txt
?
NOTE: I don't know what is the name of the file (I am write a function that gets argument in type of FILE*
that someone already opened in the main).
For example:
FILE* fd = fopen("a.txt","w");
assert(fd != NULL); // it's not important for this question.
fprintf(fd,"hello1\n");
fprintf(fd,"hello2\n");
//.... and now I want to remove all the text from a.txt. How can I do it?
// The cleaning will be in other function that get just fd (without the
// name of the file)
fclose(fd);