...
| Code Block | ||
|---|---|---|
| ||
FILE *fd = fopen(file_name, "w+");
if (fd == NULL) {
/* Handle Error */
}
/* Write to file */
/* ... */
/* Go to beginning of file */
fseek(fd, 0, SEEK_SET);
/* Read from file */
fclose(fd);
fd = NULL;
|
Be sure to use fflush() after writing data to the file, in accordance with FIO39-C. Do not alternately input and output from a stream without an intervening flush or positioning call.
Non-Compliant Code Example (owner)
...