Update
This commit is contained in:
parent
0551934395
commit
ef715fd94d
16 changed files with 1755 additions and 1715 deletions
|
@ -142,6 +142,10 @@ if (a == b)
|
|||
|
||||
Beginners similarly often forget breaks in switch statement, which works but usually not as you want -- thankfully compilers warn you about this.
|
||||
|
||||
Also `putchar('a')` versus `putchar("a")` ;) Only the first one is correct of course.
|
||||
|
||||
**Stdlib API can be [trollish](trolling.md)**, for example the file printing functions: *fprintf* expects the file pointer as first argument while *fputs* expects it as last, so to print hello you can do either `fprintf(file,"hello")` or `fputs("hello",file)` -- naturally this leads to fucking up the order sometimes and doing so even compiles (both arguments are pointers), the running code then crashes.
|
||||
|
||||
Watch out for **operator precedence**! C infamously has weird precedence with some special operators, bracket expressions if unsure, or just to increase readability for others. Also nested ifs with elses can get tricky -- again, use curly brackets for clarity in your spaghetti code.
|
||||
|
||||
**[Preprocessor](preprocessor.md) can give you headaches** if you use it in overcomplicated ways -- ifdefs and macros are fine, but too many nesting can create real mess that's super hard to debug. It can also quite greatly slow down compilation. Try to keep the preprocessing code simple and flat.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue