getchar buffer size
i am calling getchar, and i know usually that you have to hit enter to flush the buffer and read the data with getchar. however, i see that if i input 2k characters interactively, getchar will read the data without a return. also, if i use a perl script as input, it seems i have to generate about 4k worth of characters before getchar will read it.
is there a standard buffer size that "overflows" and forces getchar to read without a carriage return? and why would i get different results between interactive and perl script?
I believe stdio's internal buffer size is defined as BUFSIZ (8192 bytes on my system.) I could be wrong, but I'm pretty sure that's what that macro is for.
EDIT: Now that I think about it, I don't think stdio's buffer size has as much as to do with it as the terminal's buffer size does. I don't think the stdio routines even see any of the data until the terminal passes it on (usually after pressing ENTER in buffered mode.)
You can set the tty characteristics on unix so that the tty returns single chars without a return required. You can also do this in console mode apps in windows.
> is there a standard buffer size that "overflows" and forces getchar to read without a carriage return?
You can try messing with setvbuf() before you call any other stdio function, but that only solves the internal 'C' runtime library buffering. Data may still be buffered by the OS before it even gets anywhere near your code.