gpt4 book ai didi

c - printf 中增量运算符的不明确行为

转载 作者:行者123 更新时间:2023-11-30 21:18:50 27 4
gpt4 key购买 nike

Possible Duplicate:
Undefined Behavior and Sequence Points

程序的输出

#include<stdio.h>
main()
{

int i = 10;
printf("%d %d %d\n", ++i, i++, ++i);

}

是 13 11 13。有人可以解释一下吗?

最佳答案

这是有史以来最古老的问题。为什么人们觉得这如此迷人?

这是未定义的行为;你依赖于没有 sequence point 的副作用修改之间。

关于c - printf 中增量运算符的不明确行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12975872/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com