Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 std::cin 可以将多长的字符串读入字符串对象?10000个字符是可能的吗?
cin是一个流,因此实际上您可以读取的字符数没有限制。如果你将它们全部缓冲在内存中,你可能会用完内存,当然,限制是由内存大小给出的,但是 10,000 个字符非常少(如果 Unicode,约为 20 KB),那么对于任何限制(即使在 16 台机器上也是如此)来说太远了...)。
cin
什么时候cin是操作系统控制台,那么用户可以输入的字符数可能会受到限制,但这取决于操作系统(无论如何您不太可能获得该限制)。