根据C99的printf / fprintf中最大尺寸 [英] printf/fprintf maximum size according to c99

查看:216
本文介绍了根据C99的printf / fprintf中最大尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C99 标准说:

这可通过任何单次转换产生的字符数
  应至少为4095

The number of characters that can be produced by any single conversion shall be at least 4095

这是否意味着最大尺寸为4095,如果是,为什么它说:至少?

Does it mean that the maximum size is 4095 if yes why its says "at least"?

推荐答案

您已经找到了C语言的规格比较烦人的方面之一。他们通常不说最大的是什么。相反,他们通常会说什么的最小允许的最大值的是

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.

这是我们是如何走到歧义符号时予以考虑只喜欢标识符的前8个字符的限制 - 他们不想强迫任何实施者处理更长的标识,所以他们所说的最大最小的长度为8。

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.

这篇关于根据C99的printf / fprintf中最大尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆