在printf的增量运算符的ambigious行为 [英] ambigious behaviour of increment operator in printf

查看:260
本文介绍了在printf的增量运算符的ambigious行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  未定义行为和顺序点

程序的输出

#include<stdio.h>
main()
{

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

}

13 11 13可有人请解释一下吗?

is 13 11 13. Can someone please explain this ?

推荐答案

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

It's the oldest question ever. Why do people find this so fascinating?

这是不确定的行为;你依靠副作用,无需修改之间的序列点

This is undefined behavior; you're relying on side-effects without a sequence point between modifications.

这篇关于在printf的增量运算符的ambigious行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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