 
                            ...
In this non-compliant code example, a device is opened for updating, data are sent to it, and then the response is read back.
| Code Block | ||
|---|---|---|
| 
 | ||
| 
/* location to be read or written to */
const char *filename = "/dev/device2";
FILE *file = fopen(filename, "rb+");
if (file == NULL) {
  /* handle error */
}
/* write to file stream */
/* read response from file stream */
fclose(file);
 | 
...
In this compliant solution, fflush() is called in between the output and input.
| Code Block | ||
|---|---|---|
| 
 | ||
| 
/*location to be read or written to */
const char *filename = "/dev/device2";
FILE *file = fopen(filename, "rb+");
if (file == NULL) {
  /* handle error */
]
/* write to file stream */
fflush(file);
/* read response from file stream */
fclose(file);
 | 
...