printf/fprintf 最大尺寸根据 c99
The C99 standard says:
The number of characters that can be produced by any single conversion
shall be at least 4095
Does it mean that the maximum size is 4095 if yes why its says "at least"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您已经发现了 C 语言规范中最令人烦恼的方面之一。他们通常不会说出最大值是多少。相反,他们通常会说出最大值的最小允许值是多少。
他们认识到不同的硬件/编译器/链接器环境有不同的限制,因此他们将大部分限制留给了各个工具作者。但是,他们希望在环境之间提供一定程度的可移植性,因此他们指定了最大值可以采用的最低值。
这就是我们如何得到限制,例如在消除符号歧义时只考虑标识符的前 8 个字符——他们不想强迫任何实现者处理更长的标识符,因此他们说“最小最大”长度是 8。
这是同样的故事 - 他们希望程序员能够使用适当大小的转换,但认识到某些平台可能无法处理巨大转换 - 因此他们设置了足够大的大小大多数程序员永远不知道关于限制,但足够小,以至于某些实现只能执行最低限度的操作并且仍然符合要求。
You've found one of the more annoying aspects of the C language specifications. They don't usually say what a maximum is. Instead, they'll usually say what the smallest allowed value for a maximum is.
They recognized that different hardware / compiler / linker environments have different restrictions, so they left most of the limits up to the individual tool authors. However, they wanted to provide some amount of portability between environments, so they specified the lowest values that maximums could take.
This is how we got restrictions like only the first 8 characters of identifiers being taken into account when disambiguating symbols -- they didn't want to force any implementor to deal with longer identifiers, so they said the "least maximum" length was 8.
It's the same story here -- they wanted programmers to be able to use decent-sized conversion, but recognized some platforms may not be able to handle huge conversions -- so they put in place a size large enough for most programmers to never know about the limit, but small enough that some implementations can do only the minimum and still be compliant.
实现编译器必须允许至少 4095 个字符,但也允许更多。
Implementing compilers must allow at least 4095 characters but more is allowed.
“至少”意味着它是最小值,而不是最大值。
实现必须至少支持这么多,但可以支持更多。
"at least" means it is a minimum, not a maximum.
Implementations must support at least that much, but can support more.
C 标准没有指定最大值。他们所指定的是允许的最小值和最大值。
The C standard doesn't specify a maximum. What they do specify is the minimum value the maximum is allowed to be.