From e026dabefbff3b213781e475e22f7aba761c334d Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Thu, 16 Jun 2011 21:33:57 -0400 Subject: [PATCH] futzing with stdout flushing solutions --- .gitignore | 2 ++ gowrikumar/03b-stdoutbuf.c | 23 +++++++++++++++++++++++ gowrikumar/03c-stdoutbuf.c | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 gowrikumar/03b-stdoutbuf.c create mode 100644 gowrikumar/03c-stdoutbuf.c diff --git a/.gitignore b/.gitignore index ba46549..740fcd7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ gowrikumar/00-sizeof gowrikumar/02-dowhile gowrikumar/03-stdoutbuf +gowrikumar/03b-stdoutbuf +gowrikumar/03c-stdoutbuf diff --git a/gowrikumar/03b-stdoutbuf.c b/gowrikumar/03b-stdoutbuf.c new file mode 100644 index 0000000..deb9800 --- /dev/null +++ b/gowrikumar/03b-stdoutbuf.c @@ -0,0 +1,23 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +#include + +int main() +{ + printf("This time we'll include \\n!\n"); + printf("(Hit ^C to stop the madness.)\n"); + while(1) + { + fprintf(stdout, "hello-out\n"); + fprintf(stderr, "hello-err\n"); + sleep(1); + } + return 0; +} + + +/* vim:filetype=c:fileencoding=utf-8 + */ diff --git a/gowrikumar/03c-stdoutbuf.c b/gowrikumar/03c-stdoutbuf.c new file mode 100644 index 0000000..0402ec2 --- /dev/null +++ b/gowrikumar/03c-stdoutbuf.c @@ -0,0 +1,24 @@ +/** + * :author: Dan Buch (daniel.buch@gmail.com) + */ + +#include +#include + +int main() +{ + printf("This time we'll flush stdout!\n"); + printf("(Hit ^C to stop the madness.)\n"); + while(1) + { + fprintf(stdout, "hello-out "); + fprintf(stderr, "hello-err "); + fflush(stdout); + sleep(1); + } + return 0; +} + + +/* vim:filetype=c:fileencoding=utf-8 + */