I've written a simple C program that is meant to pipe stdin
to stdout
without buffering characters:
#include <stdio.h>
int main (int argc, char *argv[])
{
int c;
while ((c = getchar()) != -1) {
putchar(c);
fflush(stdout);
}
return 0;
}
However, this program still seems to be buffering characters until newlines, despite the call to fflush
. Why is this happening and how can I fix it (if possible)?