Are there any stdin input length limitations (in amount of input or input speed)?
There aren't any length limits on stdin
. If you can't receive large amounts of data it's your code that creates the problems.
According to everyone's other favorite Q&A site:
There shouldn't be a limit to the stream size (whether that's stdin or another). What you might want to check however, is where you store these characters ... Is there enough space to store them all ?
Try just code like this (without storing !) :
int c = 0;
do {
c = getc(stdin);
printf("%c", (char) c);
} while (c != EOF); /* <--- or another terminator value */
and see whether it has the same restriction.
There are limits in the speed of transfer. In general, they are approximately the same as any "UNIX" pipe. There are more efficient mechanisms offered by most operating systems, but pipes are quite fast... assuming you're not using printf & such.
No. stdin
has no limits on length or speed.
If you want to get gigabytes of data via stdin
you can, and your computer will supply it as fast as it can.
It probably depends on the stdin driver !
stdin (as a concept) has no limitation.
I expect that kernel developers (of any systems) have made some design choices which add limitations.
Try it:
The yes
unix command outputs lines of y
endlessly. Pipe it to a C program that just reads stdin and puts it on stdout (e.g. cat
, but tr 'y' 'y'
also works). Wait until cat
crashes or your patience reaches its limit:
yes | cat
About the speed factor, limits are not determined by language or OS but by hardware (CPU, RAM, hard-disk, SATA, network, ...)