printf的转换规格的大小限制 [英] size limit of printf conversion specification

查看:509
本文介绍了printf的转换规格的大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的printf 转换规范其次是标志,宽度,precision,长度修改和转换符 。是否有实际的限制转换规格的大小?

printf conversion specifications are % followed by flags, width, precision, length modifier and conversion specifier. Is there practical limit to size of a conversion specification?

即。 %S 是2个字符长,而%08.2f 是6个字符长。我的问题是,什么是可以创建一个格式字符串的最大单颗规格的长度,按C99标准?

I.e. %s is 2 chars long, while %08.2f is 6 chars long. My question is, what is the length of the maximal single specification in a format string that can be created, according to C99 standard?

推荐答案

有最大长度没有这样的转换规范。如果你认为你已经找到了这样一个规范,我可以想出一个是一个字符长。

There is no such conversion specification of maximum length. If you think you've found such a spec, I can come up with one that is one char longer.

例如,考虑字段宽度和precision。标准说,他们是十进制整数,但没有指定自己的范围。因此,您可以编写转换说明与任意大的整数作为字段宽度或precision。

For example, consider field width and precision. The standard says they are decimal integers but does not specify their range. Therefore you can write conversion specifiers with arbitrarily large integers as field width or precision.

这篇关于printf的转换规格的大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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