We use cookies.This website uses essential cookies to operate core features. With your consent, we also use analytics cookies to understand traffic and improve the service. For more details, see our .
Was this tool helpful to use?
Your feedback helps us make it better
Check C operator precedence and associativity online to easily understand and evaluate complex expressions.
A curated syntax reference, not a compiler or example validator. Local group numbers do not replace version-specific grammar, typing or evaluation rules. Examples keep their original code and literals. Reference
a++PostfixLeft-to-right先返回当前值,然后将变量加 1。
i++a--PostfixLeft-to-right先返回当前值,然后将变量减 1。
i--a()PostfixLeft-to-right调用函数并传递参数。
printf("hi")a[]PostfixLeft-to-right访问数组的元素,等价于 *(a+i)。
arr[0].PostfixLeft-to-right访问结构体或联合体的成员。
obj.name->PostfixLeft-to-right通过指针访问结构体或联合体成员,等价于 (*p).x。
p->next(type){list}PostfixLeft-to-rightC99 起在表达式中创建一个匿名对象并初始化。
(int[]){1,2,3}++aUnaryRight-to-left先将变量加 1,再返回新值。
++i--aUnaryRight-to-left先将变量减 1,再返回新值。
--i+aUnaryRight-to-left返回操作数的值,触发整型提升。
+x-aUnaryRight-to-left返回操作数的相反数。
-x!UnaryRight-to-left对操作数取反,0 变 1,非 0 变 0。
!ready~UnaryRight-to-left对整数按位取反,0 变 1,1 变 0。
~mask(type)UnaryRight-to-left将表达式显式转换为目标类型。
(int)3.14*aUnaryRight-to-left读取指针所指向地址处的值。
*p&aUnaryRight-to-left获取变量在内存中的地址。
&valuesizeofUnaryRight-to-left返回类型或表达式占用的字节数,编译期求值。
sizeof(int)_AlignofUnaryRight-to-leftC11 起返回类型的对齐字节数。
_Alignof(double)*MultiplicativeLeft-to-right两个操作数相乘。
a * b/MultiplicativeLeft-to-right整数除法向零截断;浮点除法保留小数。
10 / 3%MultiplicativeLeft-to-right返回两个整数相除的余数,操作数必须为整型。
10 % 3+AdditiveLeft-to-right两数相加,或指针与整数相加得到偏移地址。
a + b-AdditiveLeft-to-right两数相减,或两个指针相减得到偏移元素个数。
a - b<<ShiftLeft-to-right整数按位左移,相当于乘以 2 的幂。
1 << 3>>ShiftLeft-to-right整数按位右移,有符号数实现定义、无符号数为逻辑右移。
8 >> 2<RelationalLeft-to-right比较两个操作数,左小于右返回 1,否则返回 0。
a < b<=RelationalLeft-to-right左小于或等于右返回 1,否则返回 0。
a <= b>RelationalLeft-to-right左大于右返回 1,否则返回 0。
a > b>=RelationalLeft-to-right左大于或等于右返回 1,否则返回 0。
a >= b==EqualityLeft-to-right判断两个值是否相等。
a == b!=EqualityLeft-to-right判断两个值是否不相等。
a != b&BitwiseLeft-to-right两个整数按位执行逻辑与,两位都为 1 时结果为 1。
a & b^BitwiseLeft-to-right两个整数按位执行异或,相同为 0、不同为 1。
a ^ b|BitwiseLeft-to-right两个整数按位执行逻辑或,任一位为 1 结果为 1。
a | b&&LogicalLeft-to-right短路逻辑与:左操作数为 0 时不计算右操作数。
a && b||LogicalLeft-to-right短路逻辑或:左操作数为非 0 时不计算右操作数。
a || b?:ConditionalRight-to-left根据条件返回两个表达式之一。
x > 0 ? 1 : -1=AssignmentRight-to-left将右操作数的值赋给左操作数。
x = 10+=AssignmentRight-to-leftx = x + y 的简写。
x += 1-=AssignmentRight-to-leftx = x - y 的简写。
x -= 1*=AssignmentRight-to-leftx = x * y 的简写。
x *= 2/=AssignmentRight-to-leftx = x / y 的简写。
x /= 2%=AssignmentRight-to-leftx = x % y 的简写。
x %= 3<<=AssignmentRight-to-leftx = x << y 的简写。
x <<= 2>>=AssignmentRight-to-leftx = x >> y 的简写。
x >>= 2&=AssignmentRight-to-leftx = x & y 的简写。
x &= 0xFF^=AssignmentRight-to-leftx = x ^ y 的简写。
x ^= mask|=AssignmentRight-to-leftx = x | y 的简写。
x |= 0x01,CommaLeft-to-right依次求值左、右操作数,整个表达式的结果为右操作数的值,常用于 for 语句步进。
for (i=0,j=9; i<j; ++i,--j)Overview
Understand what the tool solves, how it works, and the boundaries of its data.
This reference filters C operator entries by text, category, and associativity. Each entry shows a symbol or form, its category, a numbered precedence level, an explanation, and an example. In this list, level 1 is highest and level 15 is lowest. These numbers are a convenient index for the page; the C language specification defines grouping through its expression grammar.
Precedence decides how operators of different levels bind. For example, a + b * c groups as a + (b * c). Associativity helps group repeated operators at the same level: a - b + c groups as (a - b) + c. Neither concept by itself tells you which operand is evaluated first. The C11 draft N1570 treats expression syntax and evaluation behavior separately.
This page is specifically a C operator reference. Similar-looking C++ or C# charts can differ, so check the language named by your project before applying a rule.
Guide
Follow the workflow and verify inputs and outputs with practical examples.
Enter a symbol, operator name, example text, or level number in the keyword field.
Select a category such as arithmetic, relational, bitwise, assignment, or comma; leave the category at All to include every group.
Choose left, right, or no associativity when you need to narrow the list further.
Read the matching level and example, then add parentheses in your own notes or code to make the intended grouping visible.
A symbol can have more than one C use. For example, * can mean multiplication or unary indirection. Search the symbol and use the category filter to distinguish entries. Clear other filters if the list is empty.
Use cases
See how the tool fits into real work and everyday tasks.
Check the levels of its operators, then rewrite the grouping with parentheses before explaining the expression to a teammate.
Compare examples at adjacent levels, such as equality and bitwise AND, and use the level number to find the corresponding entries.
When an expression is easy to misread, confirm its grouping and consider adding parentheses so the intended structure is apparent.
Q&A
Find concise answers to common questions and confusing cases.
No. Associativity describes syntax grouping, not a general execution sequence. C has separate rules for operand evaluation and side effects.
No. It filters a fixed reference list; it does not compile or validate a complete expression.
They are distinct languages with distinct specifications. Use the chart and language standard appropriate to the source file you are reading.
Notes
Review scope, result limitations, and important precautions before use.
The list is a reference, not a compiler, type checker, or execution-order analyzer. Do not infer operand timing from precedence or associativity, especially in expressions with side effects. For compatibility questions, consult the C version selected by your project and its compiler documentation. Parentheses can make intended grouping clearer.
Related
Discover related tools, collections, and available API capabilities.