here's my two cents:
- Streams are very much a unix rooted concept. The three basic streams, in or out of C, would be "stdin" (standard input) "stdout" (standard output) and stderr (usually synonymous w/ stdout).
- While they usually relate to hardware (input from keyboard, output to screen), they do not necessarily or exactly. For example, I assume the main reason for having a "stderr" is that it can be redirected and seperated from stdout.
- "I have read that unbuffered I/O is when the data comes straight from the os/kernel to your program, and buffered I/O stores the data in an intermediary buffer before doing something with it." I think in the context of programming, the difference between "unbuffered" and "buffered" would be (respectively) the difference between data recieved byte by byte and data recieved in larger blocks. For example, you can work with text by character or you can work with text by line/string. In either case, the data is being manipulated in physical memory by the OS/CPU (a "buffer" is conceptual).
- This all becomes important when a buffer may have to fill up before it's released, eg. a three letter word may leave an eight byte buffer hanging, like the remainder in long division. I don't know if or when this becomes much of an issue in C, but it can be elsewhere.
Code:
#include <stdio.h>
int main () {
int chr;
while (chr = fgetc(stdin)) putchar(chr);
}
See streams flowing thru this one? Water is the way...