A punctuator is a token that has syntactic and
semantic meaning to the compiler, but the exact significance depends
on the context. A punctuator can also be a token that is used in the
syntax of the preprocessor.
C99 and C++ define the following tokens
as punctuators, operators, or preprocessing tokens: Table 1. C and C++ punctuators[ ] |
( ) |
{ } |
, |
: |
; |
* |
= |
… |
# |
|
|
. |
-> |
++ |
-- |
## |
|
& |
+ |
- |
~ |
! |
|
/ |
% |
<< |
>> |
!= |
|
< |
> |
<= |
>= |
== |
|
‸ |
| |
&& |
|| |
? |
|
*= |
/= |
%= |
+= |
-= |
|
<<= |
>>= |
&= |
‸= |
|= |
|
In addition to
the C99 preprocessing tokens, operators, and punctuators, C++ allows
the following tokens as punctuators:
Table 2. C++ punctuators:: |
.* |
->* |
new |
delete |
|
and |
and_eq |
bitand |
bitor |
comp |
|
not |
not_eq |
or |
or_eq |
xor |
xor_eq |
Alternative tokens
Both C and C++ provide the following alternative representations
for some operators and punctuators. The alternative representations
are also known as digraphs. Operator or punctuator |
Alternative representation |
{ |
<% |
} |
%> |
[ |
<: |
] |
:> |
# |
%: |
## |
%:%: |
Note: The recognition of these alternative
representations is controlled by the DIGRAPHS option; for more information,
see
Digraph characters.
In addition to the operators and punctuators listed
above, C++ and C at the C99 language level provide the following alternative
representations. In C, they are defined as macros in the header file iso646.h. Operator or punctuator |
Alternative representation |
&& |
and |
| |
bitor |
|| |
or |
^ |
xor |
~ |
compl |
& |
bitand |
&= |
and_eq |
|= |
or_eq |
^= |
xor_eq |
! |
not |
!= |
not_eq |