# C C is a versatile, mature and efficient language. Expressions are a combination of operators and operands. An expression followed by a semmicolon (";") is a statement (it is an action) C concepts [Memory Management](Memory_Management) [Structs](Structs) [Debug messages](Debug_messages) [Random numbers](/linux/random_numbers) # Defines In C you can define stuff that's quickly replaced by the preprocessor. Let's say you have the following program: ```c #include int main() { printf("Hello, World!\n"); #ifdef DEBUG printf("Secret debug info!\n"); #endif return 0; } ``` Compile it with `gcc -o prog -c prog.c -DDEBUG`. Your program will print out the secret debug info in addition to its regular output. This is useful for debugging and more. # Storage-class specifiers Make a variable's storage class more explicit to the compiler. * static - block scope Block-scope static variables will keep their values between function calls. They're only initialized once at program startup, unlike regular function variables. * static - file scope File-scope static variables (outside of any function) are restricted to the current source file only. You can't access them from another source file. Notes ----- * Strings can be literals or arrays. Deep down, they're just pointers to the start of the char array. However, string literals are stored read-only and **cannot be modified**: ``char* s;`` If you want to make a mutable string, declare it as an array of characters: ``char s[];`` * The arrow operator (->) is used to access fields in a pointer to a struct. For example: ``thinkpad->price = 800;`` (``thinkpad`` is a pointer to a ``struct laptop thinkpad`` struct) This is useful instead of writing it as ``(*thinkpad).price = 800;`` * Include `` for fixed-size types such as `uint64_t` See also -------- https://beej.us/guide/bgc/ -> Great funny introduction to C https://c-faq.com/index.html -> C FAQs, very useful https://www.learn-c.org/ -> wip C guide http://web.archive.org/web/20080217222203/http://c.snippets.org/ Useful public domain C snippets https://www.andreinc.net/2023/02/01/demystifying-bitwise-ops#number-systems interesting article about binary operators and memory in general https://verplant.org/oo_programming_in_c.shtml OOP?