C-Kurs 2009/Vortrag01: Unterschied zwischen den Versionen
Mario (Diskussion | Beiträge) K (Sebastian mehr Arbeit gemacht...) |
Mario (Diskussion | Beiträge) K (SPs Beispiel) |
||
Zeile 8: | Zeile 8: | ||
** Syntax | ** Syntax | ||
** Operatoren | ** Operatoren | ||
+ | *** ! ~ | ||
+ | *** + - * / % ^ | & || && . [->] | ||
+ | *** ++ -- (++x vs x++) | ||
+ | *** << >> | ||
+ | *** += -= *= /= %= |= &= != ~= ^= | ||
+ | *** <<= >>= | ||
+ | *** Hirarchie | ||
+ | **** ''++x*3'' ? | ||
+ | **** '''TODO''' Weitere Beispiele! (andere Resultate, andere Parameter) | ||
+ | // Von Sebastian P. | ||
+ | #include <stdio.h> | ||
+ | int | ||
+ | main(void) { | ||
+ | const int APPLE = 1; | ||
+ | const int PEAR = 2; | ||
+ | const int MILK = 4; | ||
+ | const int FRUIT_MASK = APPLE | PEAR; | ||
+ | const int meal = MILK | PEAR; | ||
+ | /* Test: Does the meal contain fruits? */ | ||
+ | printf("%d\n", meal & FRUIT_MASK != 0); /* 0, precendence fail */ | ||
+ | printf("%d\n", (meal & FRUIT_MASK) != 0); /* 1, as expected */ | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | |||
+ | *** x ? x : x | ||
+ | |||
* Hello World | * Hello World | ||
* Compilereinführung | * Compilereinführung |
Version vom 9. September 2009, 19:21 Uhr
Inhaltsverzeichnis
Einführung
Vortragende: Sebastian D. <dyroff cs.tu-berlin.de>
Themen
- Organisatorisches
- Konzept von C
- Syntax
- Operatoren
- ! ~
- + - * / % ^ | & || && . [->]
- ++ -- (++x vs x++)
- << >>
- += -= *= /= %= |= &= != ~= ^=
- <<= >>=
- Hirarchie
- ++x*3 ?
- TODO Weitere Beispiele! (andere Resultate, andere Parameter)
// Von Sebastian P. #include <stdio.h> int main(void) { const int APPLE = 1; const int PEAR = 2; const int MILK = 4; const int FRUIT_MASK = APPLE | PEAR; const int meal = MILK | PEAR; /* Test: Does the meal contain fruits? */ printf("%d\n", meal & FRUIT_MASK != 0); /* 0, precendence fail */ printf("%d\n", (meal & FRUIT_MASK) != 0); /* 1, as expected */ return 0; }
- x ? x : x
- Hello World
- Compilereinführung