[英]What happens when I give strftime invalid specifier?
我尝试提供strftime不在列表中的修饰符%k,并且打印11,当我提供不在列表中的修饰符时,strftime会做什么?
From the C standard of strftime
: 从
strftime
的C标准:
6 If a conversion specifier is not one of the above, the behavior is undefined.
6如果转换说明符不是上述之一,则行为未定义。
You can see the list of format specifiers for strftime. 您可以看到strftime 的格式说明符列表 。 So what you are getting is an undefined behavior .
因此,您得到的是未定义的行为 。
See the manual which says about %k 请参阅说明“%k”的手册
%k The hour (24-hour clock) as a decimal number (range 0 to 23);
%k小时(24小时制),为十进制数字(范围为0到23); single digits are preceded by a blank.
单个数字后跟一个空格。 (See also %H.) (TZ)
(另请参阅%H。)(TZ)
%k
- The hour as a decimal number, using a 24-hour clock like%H
, but padded with blank (range 0 through 23).%k
以十进制数表示的小时,使用%H
类的24小时制时钟,但用空格填充(范围为0到23)。
But this format is a GNU extension. 但是这种格式是GNU扩展。 See here listed specifiers .
请参阅此处列出的说明符 。
And if the specifier not listed is used code will exbhit undefined behaviour . 如果未使用该说明符,则代码将显示未定义的行为 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.