什么是输出printf("%d");或printf("%p");声明?
当然我知道我应该传递参数,因为printf期待一个,但假设我将把这个留空将会发生什么?
我知道这会从堆栈中读取一些值(从应该放置函数参数的地方).假设我正在运行Linux机器,我可以期待这将是一些有效的值(例如函数返回地址)吗?
这只是未定义的行为.什么事情都可能发生.提供更准确的答案是不可能的.
The details depend on how printf is implemented by the library, and how variable arguments are implemented by your compiler. Look at the source of the library and/or the generated assembly to find out what's happening on your platform.