C中两个变量之间的3个加号(如a+++b) [英] 3 plus symbols between two variables (like a+++b) in C

查看:21
本文介绍了C中两个变量之间的3个加号(如a+++b)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <stdio.h>

int main()
{
    int a=8,b=9,c;
    c=a+++b;
    printf("%d%d%d
",a,b,c);
    return 0;
}

上面的程序输出a=9 b=9c=17.在 a+++b 中,为什么编译器采用 a++ 然后加上 b.为什么不使用 a +++b?这个a+++b 有具体的名称吗?请帮我理解.

The program above outputs a=9 b=9 and c=17. In a+++b why is the compiler takes a++ and then adds with b. Why is it not taking a + and ++b? Is there a specific name for this a+++b. Please help me to understand.

推荐答案

我喜欢 专家 C 编程:

ANSI 标准指定了一个约定,该约定被称为最大咀嚼策略.Maximal munch 说如果还有更多与下一个标记的一种可能性相比,编译器更愿意咬掉涉及最长字符序列的那个.所以示例将被解析

The ANSI standard specifies a convention that has come to be known as the maximal munch strategy. Maximal munch says that if there's more than one possibility for the next token, the compiler will prefer to bite off the one involving the longest sequence of characters. So the example will be parsed

c = a++ + b;

这篇关于C中两个变量之间的3个加号(如a+++b)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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