...
| Code Block | ||
|---|---|---|
| ||
char *file_name; FILE *file; /* initialize file+_name */ file = fopen(file_name, "w+"); if (fopen == NULL) { /* handle error condition */ } /* ... */ if (remove(file_name) != 0) { /* handle error condition */ } /* continue performing I/O operations on file */ fclose(file); |
Some implementations will not remove "myfile" the file specified by file_name because the stream is still open.
...
| Wiki Markup |
|---|
This compliant solution uses the POSIX {{unlink()}} function to remove the file. The {{unlink()}} function is guaranteed to unlink the file from the file system hierarchy but keep the file on disk until all open instances of the file are closed) is used \[[Open Group 04|AA. C References#Open Group 04]\]. |
...