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 .
If this tool helped you, you can buy us a coffee ☕
Check C operator precedence and associativity online to easily understand and evaluate complex expressions.
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)When writing or reading C code, unfamiliarity with operator precedence and associativity often leads to expression evaluation errors. This tool provides a comprehensive list of precedence levels and associativity directions for all C language operators. It also supports interactive querying, helping you quickly confirm the precedence and associativity of any operator to accurately understand or write complex expressions.
The precedence table displayed in this tool is based on standard C (C89/C99/C11). Please note that compiler-specific extension operators may not be included. The query results are for reference only; it is recommended to verify them against your code logic. This tool runs entirely in your browser and does not upload any input data, ensuring your privacy. If you cannot find a specific operator in the table, it may not be supported by standard C or it might be a preprocessor directive.
Mastering operator precedence can reduce unnecessary parentheses, improving code readability and execution efficiency. However, for maintainability, it is a good practice to use parentheses to clarify your intent in potentially ambiguous expressions. For example, in the expression (a & mask) == b, the bitwise AND operator has a lower precedence than the relational operator, so parentheses are required to ensure the bitwise operation is performed first. We recommend using this tool regularly for review or as a quick reference while coding.

URL to JSON Parser
Parse URL strings into structured JSON to quickly extract key information like protocols, parameters, and paths.

PYC Decompiler
Restore Python bytecode .pyc files into readable source code for easy code auditing and learning. Supports mainstream versions.

JSON to TypeScript Converter
Automatically convert JSON data into TypeScript interfaces or type aliases for frontend data modeling and API integration.

JSON Formatter
Process JSON data online: format, minify, and validate to boost your development and debugging efficiency.

URL to JSON Parser
Parse URL strings into structured JSON to quickly extract key information like protocols, parameters, and paths.

PYC Decompiler
Restore Python bytecode .pyc files into readable source code for easy code auditing and learning. Supports mainstream versions.

JSON to TypeScript Converter
Automatically convert JSON data into TypeScript interfaces or type aliases for frontend data modeling and API integration.

JSON Formatter
Process JSON data online: format, minify, and validate to boost your development and debugging efficiency.

Code Compare
Professionally compare differences between two texts or code snippets. Highlights additions, deletions, and modifications to assist with code review, document merging, and version control.