mirror of
https://github.com/LeCoupa/awesome-cheatsheets.git
synced 2026-01-28 22:28:02 -08:00
Final for C
This commit is contained in:
@@ -158,9 +158,9 @@ In Linux systems:
|
|||||||
| `!=` | Not equal, result is true or false, `a != b` |
|
| `!=` | Not equal, result is true or false, `a != b` |
|
||||||
| `&` | Bitwise and, `a & b` |
|
| `&` | Bitwise and, `a & b` |
|
||||||
| `^` | Bitwise exclusive or, `a ^ b` |
|
| `^` | Bitwise exclusive or, `a ^ b` |
|
||||||
| | | Bitwise or, `a | b` |
|
| | | Bitwise or, `a` | `b` |
|
||||||
| `&&` | Relational and, result is true or false, `a < b && c >= d` |
|
| `&&` | Relational and, result is true or false, `a < b && c >= d` |
|
||||||
| | | | Relational or, result is true or false, `a < b || c >= d` |
|
| | | | Relational or, result is true or false, `a < b` | | `c >= d` |
|
||||||
| `?` | Ternary conditional, `exp1 ? exp2 : exp3`, result is `exp2` if `exp1` is not 0, else result is `exp3` |
|
| `?` | Ternary conditional, `exp1 ? exp2 : exp3`, result is `exp2` if `exp1` is not 0, else result is `exp3` |
|
||||||
| `=` | Store |
|
| `=` | Store |
|
||||||
| `+=` | Add and store |
|
| `+=` | Add and store |
|
||||||
@@ -191,11 +191,11 @@ In Linux systems:
|
|||||||
| LR | `==`, `!=` |
|
| LR | `==`, `!=` |
|
||||||
| LR | `&` |
|
| LR | `&` |
|
||||||
| LR | `^` |
|
| LR | `^` |
|
||||||
| LR | `|` |
|
| LR | | |
|
||||||
| LR | `&&` |
|
| LR | `&&` |
|
||||||
| LR | `||` |
|
| LR | | | |
|
||||||
| RL | `? :` |
|
| RL | `? :` |
|
||||||
| RL | `=`, `+=`, `-=` ,`*=`, `/=`, `%=`, `>>=`, `<<=`, `&=`, `^=`, `|=` |
|
| RL | `=`, `+=`, `-=` ,`*=`, `/=`, `%=`, `>>=`, `<<=`, `&=`, `^=`, |= |
|
||||||
| LR | `,` |
|
| LR | `,` |
|
||||||
|
|
||||||
|
|
||||||
@@ -230,5 +230,3 @@ In Linux systems:
|
|||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
|
|
||||||
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 */
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user