ISO C99: 7.19.6.3 The printf function
梗概
#include <stdio.h>
int printf(const char * restrict format, ...);
The printf function is equivalent to fprintf with the argument stdout interposed before the arguments to printf.
7.19.6.1 The fprintf function
7.19.6.1.9
If a conversion specification is invalid, the behavior is **undefined**. If any argument is not the correct type for the corresponding conversion specification, the behavior is **undefined**.
所以,你的代码调用未定义行为 [(ISO C99 3.4.3) behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes **no requirements**
]
应该始终段错误的权利!?
不一定,未定义行为意味着任何东西都可能发生。
只是提到它:我知道这是测试代码,但在大多数情况下,您可能应该使用'snprintf()'而不是'sprintf()'。 – ereOn 2010-07-13 09:23:03
除非你需要测试你的代码是否与严重不合规的编译器兼容,否则我会考虑用本世纪的东西替换Visual Studio 6。 – 2010-07-13 09:56:54
所有答案都是不确定的行为 - 但是,只是一个想法:你*正面* bla是空吗?它可能是未初始化的?这是系统之间差异的更常见原因。 – 2010-07-13 10:16:50