Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is stdin limited in length?

Tags:

c++

c

stdin

Are there any stdin input length limitations (in amount of input or input speed)?

like image 631
Rella Avatar asked Mar 12 '10 02:03

Rella


4 Answers

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.

like image 79
egrunin Avatar answered Sep 22 '22 23:09

egrunin


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 !) :

for (;;) {
    int c = getc(stdin);
    if (c == EOF) { break; }
    putc(c, stdout);
}

and see whether it has the same restriction.

like image 37
Justin Ethier Avatar answered Sep 24 '22 23:09

Justin Ethier


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.

like image 35
jag Avatar answered Sep 22 '22 23:09

jag


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.

like image 36
sth Avatar answered Sep 25 '22 23:09

sth