mirror of
https://github.com/LeCoupa/awesome-cheatsheets.git
synced 2026-01-28 22:28:02 -08:00
66 lines
1.7 KiB
Plaintext
66 lines
1.7 KiB
Plaintext
|
|
Operator precedence
|
|
|
|
More precedence
|
|
|
|
LR ( ) [ ] -> . x++ x--
|
|
RL ! ~ - + ++x --x * & sizeof (type)
|
|
LR * / %
|
|
LR + -
|
|
LR << >>
|
|
LR < <= > >=
|
|
LR == !=
|
|
LR &
|
|
LR ^
|
|
LR |
|
|
LR &&
|
|
LR ||
|
|
RL ? :
|
|
RL = += -= *= /= %= >>= <<= &= ^= |=
|
|
LR ,
|
|
|
|
Less precedence
|
|
|
|
|
|
Function definition
|
|
|
|
type function_name(int a, float b, const char * ch,...) { function_body }
|
|
|
|
/* only parameters passed by address can are modified*/
|
|
|
|
/* in the calling function, local copy can be modified*/
|
|
|
|
char * strcpy( char * s1, const char * s2 ) { statements }
|
|
|
|
Declarations forms
|
|
|
|
basic_type variable;
|
|
|
|
type variable[val][val]...[val]={data,data,...}; /*multidimensional array*/
|
|
|
|
struct struct_name { /* struct_name is optional */
|
|
type variable_1; /* any declaration */
|
|
… /* all variable names must be unique*/
|
|
} variable_1, ... ; /* variables are optional */
|
|
|
|
struct struct_name { /* struct_name is optional */
|
|
type variable_1: length; /* any declaration : length in bits */
|
|
... /* type is int, unsigned or signed */
|
|
} variable_1, ... ; /* variables are optional, they can also be arrays and pointers */
|
|
|
|
|
|
union union_name { /* union_name is optional */
|
|
type variable_1; /* variable_1 overlays variable_2 */
|
|
type variable_2;
|
|
...
|
|
} variable_a, ...; /* variables are optional */
|
|
|
|
enum enum_type /* enum_name is optional */
|
|
{ enumeration_name_1, /* establishes enumeration literals */
|
|
enumeration_name_2=number,/* optional number, */
|
|
... /* default is 0, 1, 2, ... */
|
|
} variable, ...; /* variables are optional */
|
|
|
|
/* use dot notation to select a component of a struct or union */
|
|
|