Punctuation
From cppreference.com
These are the punctuation symbols in C. The meaning of each symbol is detailed in the linked pages.
{
}
- In a struct or union definition, delimit the struct-declaration-list.
- In a enum definition, delimit the enumerator list.
- Delimit a compound statement. The compound statement may be part of a function definition.
- In initialization, delimit the initializers.
[
]
- Subscript operator.
- Part of array declarator in a declaration or a type-id.
- In initialization, introduce a designator for an array element. (since C99)
- In a attribute specifier, delimit the attributes. (since C23)
#
- Introduce a preprocessing directive.
- The preprocessing operator for stringification.
##
(
)
- In a expression, indicate grouping.
- Function call operator.
- In a
sizeof
or_Alignof
(since C11) expression, delimit the operand. - In a explicit cast, delimit the type-id.
- In a compound literal, delimit the type-id. (since C99)
- In a declaration or a type-id, indicate grouping.
- In a function declarator (in a declaration or a type-id), delimit the parameter list.
- In a
if
,switch
,while
,do-while
, orfor
statement, delimit the controlling clause. - In a function-like macro definition, delimit the macro parameters.
- Part of a
defined
,__has_include
, or__has_c_attribute
(since C23) preprocessing operator. - Part of a generic selection expression. (since C11)
- In an
_Atomic
type specifier, delimit the type-id. (since C11) - In a static assertion declaration, delimit the operands. (since C11)
- In an
_Alignas
specifier, delimit the operand. (since C11) - In an attribute, delimit the attribute arguments. (since C23)
;
- Indicate the end of
- a statement (including the init-statement of a for statement)
- a declaration or struct-declaration-list
- Separate the second and third clauses of a for statement.
:
- Part of conditional operator.
- Part of label declaration.
- In a bit-field member declaration, introduce the width.
...
- In the parameter list of a function declarator, signify a variadic function.
- In a macro definition, signify a variadic macro. (since C99)
?
- Part of conditional operator.
- In a generic association, delimit the type-id or default and the selected expression. (since C11)
::
- In a attribute, indicate attribute scope. (since C23)
.
- Member access operator.
- In initialization, introduce a designator for a struct/union member. (since C99)
->
~
!
+
-
*
- Indirection operator.
- Multiplication operator.
- Pointer operator operator in a declarator or in a type-id.
- Placeholder for the length of a variable-length array declarator in a function declaration. (since C99)
/
%
^
&
|
=
- Simple assignment operator.
- In initialization, delimit the object and the initializer list.
- In a enum definition, introduce the value of enumeration constant.
+=
-=
*=
/=
%=
^=
&=
|=
==
!=
<
- Less-than operator.
- Introduce a header name in a #include directive.
>
- Greater-than operator.
- Indicate the end of a header name in a
#include
directive
<=
>=
&&
||
<<
>>
<<=
>>=
++
--
,
- Comma operator.
- List separator in
- the declarator list in a declaration
- initializer list in initialization, including compound literals (since C99)
- the argument list in a function call expression
- the enumerator list in a enum declaration
- the macro parameter list in a function-like macro definition
- the generic association list in a generic selection expression (since C11)
- an attribute list (since C23)
- In a static assertion declaration, separate the arguments. (since C11)
- In a generic selection expression, seperate the controlling expression and the generic association list. (since C11)
References
- C17 standard (ISO/IEC 9899:2018):
- 6.4.6 Punctuators (p: 52-53)
- C11 standard (ISO/IEC 9899:2011):
- 6.4.6 Punctuators (p: 72-73)
- C99 standard (ISO/IEC 9899:1999):
- 6.4.6 Punctuators (p: 63-64)
- C89/C90 standard (ISO/IEC 9899:1990):
- 3.1.6 Punctuators
See also
Alternative representations (C95) | alternative spellings for certain operators |