Is there a limit for the IO buffers?

  archlinux, c++

I want to let the users input strings with more than 4,095 characters, but std::cin seems to have some sort of undocumented limit and keeps cutting off the string to only allow 4,095 characters.

Is there some way to get past this "limit" using one of the many input functions, preferably allowing any length or should I opt to choose another programming language? There might not be a limit in the standard, but Arch Linux may have an input buffer limit.

The strings may reach lengths of 1 ≤ L ≤ 10e6 where L is the length of the string.

int main() {
    /* The user inputs a string with more than
       4095 characters. 

       Let's say that every character in the string
       is 'a' except for the 4095th character in the 
       string, which is 'B', and the end of the string 
       looks like "...aaBaaaaaaaaaaaaa"
       
       The string will get cut off to "...aaB" (4095 
       characters) meaning that there seems to be some 
       sort of limit. */

    std::string str;
    std::cin >> str;
}

Source: Windows Questions C++

LEAVE A COMMENT