What are C operators and Punctuators?

CServer Side ProgrammingProgramming

An operator is used to describe an operation applied to one or several objects. It is mainly meaningful in expressions, but also in declarations. It is generally a short sequence using non-alphanumeric characters.

A punctuator is used to separate or terminate a list of elements.

C operators and punctuators are as follows −

...   &&  -=  >=   ~   +   ;  ]

<<=   &=  ->  >>   %   ,   <  ^
>>=   *=  /=  ^=   &   -   =  {

!=    ++  <<  |=   (   .   >  |

%=    +=  <=  ||   )   /   ?  }

##    --  ==  !   *   :   [   #

Note that some sequences are used as operators and as punctuators, such as *, =, :, # and ,.

Several punctuators have to be used by pairs, such as ( ), [ ], { }.

When parsing the input text, the compiler tries to build the longest sequence as possible for a token, so when parsing a+++++b, the compiler will recognize the following −

a ++ ++ + b which is not a valid construct

The compiler will not consider the following −

a ++ + ++ b which may be valid
raja
Published on 01-Sep-2021 12:35:08
Advertisements