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/11 12:19] natrius [Main Function] |
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:// | ||
- | ## Input seperated with space or / | + | ### Starting a project, planning |
- | * https://stackoverflow.com/questions/15330047/understanding-scanf-dealing-with-formatted-input | + | * https://www.quora.com/How-do-I-start-my-own-programming-projects-1 |
+ | * https://www.codeconquest.com/ | ||
+ | * https:// | ||
- | To match both the space-separated and the slash-separated inputs, you'll need a modestly complex format string: | + | ### Games |
- | < | + | |
- | if (scanf(" | + | * https://www.coderbyte.com/ |
- | ...data was read properly... | + | * https://www.reddit.com/ |
- | else | + | * https:// |
- | | + | |
- | </code> | + | |
- | + | | |
- | The first conversion specification is a scan set that accepts a sequence of non-blanks, non-slashes (so it will stop at the first blank or slash). It would be best to specify an upper bound on how many characters will be accepted so as to avoid stack overflow; for example, if char name[32];, then %31[^ /] (note the off-by-one). The second conversion specification %*1[ /] accepts a single character (1) that is either a blank or slash [ /], and does not assign it to any variable (*). The third conversion specification is a standard numeric input, skipping leading blanks, allowing for negative numbers to be entered, etc. The fourth conversion specification is the same as the second, and the fifth is a standard format for a float (which means that 34000.25 with 7 significant digits is at the outer end of the range of representable values). | + | |
- | + | ||
- | Note that the ' | + | |
- | + | ||
- | ## Datentypen | + | |
- | + | ||
- | ^ Type ^ Keyword | + | |
- | | character | + | |
- | | unsigned character | + | |
- | | integer | + | |
- | | short integer | + | |
- | | long integer | + | |
- | | unsigned integer | + | |
- | | unsigned short integer | + | |
- | | unsigned long integer | + | |
- | | single-precision floating-point (7 Stellen) | + | |
- | | double-precision floating-point (19 Stellen) | + | |
## Cheat Sheet | ## Cheat Sheet | ||
Line 50: | Line 49: | ||
### Printf | ### Printf | ||
- | < | + | < |
#include < | #include < | ||
Line 72: | Line 71: | ||
### Scanf | ### Scanf | ||
- | < | + | < |
#include < | #include < | ||
Line 86: | Line 85: | ||
### Conditionals | ### Conditionals | ||
- | < | + | < |
if(flag) { | if(flag) { | ||
// put some statements here to execute if flag is true (flag != 0) | // put some statements here to execute if flag is true (flag != 0) | ||
Line 111: | Line 110: | ||
### Looping | ### Looping | ||
- | < | + | < |
while(flag) { | while(flag) { | ||
// make sure there is some statement in here to change flag to become false. | // make sure there is some statement in here to change flag to become false. | ||
Line 123: | Line 122: | ||
### Math Functions | ### Math Functions | ||
- | < | + | < |
#include < | #include < | ||
Line 134: | Line 133: | ||
th = atan2(y, x); | th = atan2(y, x); | ||
} | } | ||
- | Creating Functions | + | </ |
+ | ### Creating Functions | ||
+ | |||
+ | <code c> | ||
int functionname(type1 input1, ... , typeN *output1, ...); // this is the function prototype with the ; | int functionname(type1 input1, ... , typeN *output1, ...); // this is the function prototype with the ; | ||
int functionname(type1 input1, ... , typeN *output1, ...) | int functionname(type1 input1, ... , typeN *output1, ...) | ||
Line 145: | Line 147: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ## Input seperated with space or / | ||
+ | |||
+ | * https:// | ||
+ | |||
+ | To match both the space-separated and the slash-separated inputs, you'll need a modestly complex format string: | ||
+ | |||
+ | < | ||
+ | if (scanf(" | ||
+ | ...data was read properly... | ||
+ | else | ||
+ | ...something went wrong... | ||
+ | </ | ||
+ | |||
+ | The first conversion specification is a scan set that accepts a sequence of non-blanks, non-slashes (so it will stop at the first blank or slash). It would be best to specify an upper bound on how many characters will be accepted so as to avoid stack overflow; for example, if char name[32];, then %31[^ /] (note the off-by-one). The second conversion specification %*1[ /] accepts a single character (1) that is either a blank or slash [ /], and does not assign it to any variable (*). The third conversion specification is a standard numeric input, skipping leading blanks, allowing for negative numbers to be entered, etc. The fourth conversion specification is the same as the second, and the fifth is a standard format for a float (which means that 34000.25 with 7 significant digits is at the outer end of the range of representable values). | ||
+ | |||
+ | Note that the ' | ||
+ | |||
+ | ## Datentypen | ||
+ | |||
+ | ^ Type ^ Keyword | ||
+ | | character | ||
+ | | unsigned character | ||
+ | | integer | ||
+ | | short integer | ||
+ | | long integer | ||
+ | | unsigned integer | ||
+ | | unsigned short integer | ||
+ | | unsigned long integer | ||
+ | | single-precision floating-point (7 Stellen) | ||
+ | | double-precision floating-point (19 Stellen) | ||
## Zusammenfassung Tutorial | ## Zusammenfassung Tutorial |