meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
digital:programmieren:c [2019/01/08 17:45] natrius |
digital:programmieren:c [2022/02/22 16:44] natrius removed |
||
---|---|---|---|
Line 1: | Line 1: | ||
# C | # C | ||
+ | |||
Zusammenfassung für nützliche Sachen beim Programmieren mit C. | Zusammenfassung für nützliche Sachen beim Programmieren mit C. | ||
## Ressourcen | ## Ressourcen | ||
+ | |||
+ | * https:// | ||
* https:// | * https:// | ||
* http:// | * http:// | ||
* http:// | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * ALGORITHMS http:// | ||
+ | * Propositional Logic: Introduction https:// | ||
+ | * https:// | ||
+ | * Allgemein, MultiOS-Gamedev: | ||
+ | * https:// | ||
+ | * Structure my program https:// | ||
+ | * https:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | |||
+ | ### Starting a project, planning | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | ### Games | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * paid? - https:// | ||
+ | |||
+ | ## Cheat Sheet | ||
+ | |||
+ | ### Main Function | ||
+ | |||
+ | <code c> | ||
+ | void main(void) { | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ### Printf | ||
+ | |||
+ | <code c> | ||
+ | #include < | ||
+ | |||
+ | void main(void) { | ||
+ | int i = 1; | ||
+ | unsigned u = 2; | ||
+ | long l = 3; | ||
+ | float f = 4.0; | ||
+ | double d = 5.0; | ||
+ | char c = 6; | ||
+ | unsigned char uc = 7; | ||
+ | |||
+ | printf(" | ||
+ | i, u, l, f, d, c, c, uc); | ||
+ | |||
+ | printf(" | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ### Scanf | ||
+ | |||
+ | <code c> | ||
+ | #include < | ||
+ | |||
+ | void main(void) { | ||
+ | int i; | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ### Conditionals | ||
+ | |||
+ | <code c> | ||
+ | if(flag) { | ||
+ | // put some statements here to execute if flag is true (flag != 0) | ||
+ | } | ||
+ | |||
+ | if(flag) { | ||
+ | // put some statements here to execute if flag is true (flag != 0) | ||
+ | } else { | ||
+ | // put some statements here to execute if flag is false (flag == 0) | ||
+ | } | ||
+ | |||
+ | switch(flag) { | ||
+ | case 0: // statements | ||
+ | | ||
+ | case 1: // statements | ||
+ | break; | ||
+ | case 2: // statements | ||
+ | break; | ||
+ | default: | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ### Looping | ||
+ | |||
+ | <code c> | ||
+ | while(flag) { | ||
+ | // make sure there is some statement in here to change flag to become false. | ||
+ | } | ||
+ | |||
+ | for(i = 0; i < LAST; i++) { | ||
+ | // statements | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ### Math Functions | ||
+ | |||
+ | <code c> | ||
+ | #include < | ||
+ | |||
+ | void main(void) { | ||
+ | double th = pi/2; // th is in radians | ||
+ | double x, y; | ||
+ | |||
+ | x = cos(th); | ||
+ | y = sin(th); | ||
+ | th = atan2(y, x); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ### Creating Functions | ||
+ | |||
+ | <code c> | ||
+ | int functionname(type1 input1, ... , typeN *output1, ...); // this is the function prototype with the ; | ||
+ | int functionname(type1 input1, ... , typeN *output1, ...) | ||
+ | { | ||
+ | *output1 = // some function of the input variables. | ||
+ | *output2 = // some function of the input varialbles. | ||
+ | ... | ||
+ | return(someintvalue); | ||
+ | } | ||
+ | </ | ||
## Input seperated with space or / | ## Input seperated with space or / |