Selected Help on ANSI C

Contents

See Also

Precedence and Associativity of Operators

From highest to lowest precedence [associativity]:

()  []  ->  .                                  [L to R]
!  ~  ++  --  +  -  *  &  (type)  sizeof       [R to L]
*  /  %                                        [L to R]
+  -                                           [L to R]
<<  >>                                         [L to R]
<  <=  >  >=                                   [L to R]
==  !=                                         [L to R]
&                                              [L to R]
^                                              [L to R]
|                                              [L to R]
&&                                             [L to R]
||                                             [L to R]
?:                                             [R to L]
=  +=  -=  *=  /=  %=  &=  ^=  |=  <<=  >>=    [R to L]
,                                              [L to R]

Notes:

Preprocessing

#define DAYSPERWEEK 7
Simple textual substitution of 7 substituted for token DAYSPERWEEK. Note that in most cases, a better alternative is:
const int DaysPerWeek = 7;
#define MAX(a, b) ((a) > (b) ? (a) : (b))
Simple textual substitution with parameter replacement. Note that, unlike the corresponding function, the parameters and result may be any arithmetic type or even pointers. Also in contrast to a function, a parameter may be evaluated more than once, giving undesired effects:
MAX(++i, ++j) will increment either i twice and j once, or vice versa.
#define PATHFORMAT(d) #d "/%s"
Macro call PATHFORMAT(/usr/tmp) will be expanded to:
"/usr/tmp" "/%s"
which will be catenated to yield:
"/usr/tmp/%s"
#define JOIN(a, b) a ## b
Macro call JOIN(var, 01) will be expanded to: var01

Miscellaneous


RLR