09.07.2015 Views

Standard Input/Output Library - University of Windsor

Standard Input/Output Library - University of Windsor

Standard Input/Output Library - University of Windsor

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ExampleIntroductionStreams and FILE objectsBufferingOpening a StreamReading and writing a streamIf this is a serious issue, then we should modify our code to:#include int main(int argc, char *argv[]){FILE *f;char c;f=fopen(argv[1], "w");setbuf(f, NULL);while((c=getchar()) != EOF)fputc(c, f);}or to#include int main(int argc, char *argv[]){FILE *f;char c;f=fopen(argv[1], "w");while((c=getchar()) != EOF){fputc(c, f);fflush(f);}}<strong>Standard</strong> <strong>Input</strong>/<strong>Output</strong> <strong>Library</strong>60-256 System Programming

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!