Or login with:
stream via the stream's underlying write function. The open status of the stream is unaffected.
If the stream argument is NULL, fflush flushes all open output streams.
The function fpurge erases any input or output buffered in the given \c stream. For output streams this discards any unwritten output. For input streams this discards any input read from the underlying object but not yet obtained via getc. This includes any text pushed back via ungetc.
#include <stdio.h> int main() { char buffer[100]; // open file for both reading and writing FILE *f = fopen("rw.txt", "rt+"); if (f) { fputs("something", f); // flush the stream so we can use fgets fflush(f); fgets(buffer, 9, f); fclose(f); } return 0; }
| EBADF | The stream argument is not an open stream, or, in the case of flush, not a stream open for writing. |
You must login to leave a messge