Since fflush() is illegal, and rewind() is not guaranteed to work, is this legal, and more importantly, function the way I'm intending it to?
Code:#include <stdio.h> #include <stdlib.h> #include <stdbool.h> // Flush input buffer (actually, any buffer) // // Parameters: // FILE* stream Pointer to file to be 'debuffered'. // Returns: // bool - false if error, true if successful. // Notes: // For output streams, does not mimic fflush() in that remaining // data is lost. inline bool Flush_Stream(FILE* stream) { void* p = malloc(BUFSIZ); if (p == NULL) return false; setbuf(stream, p); return true; }



LinkBack URL
About LinkBacks



