# C programmering

Nivå: beginner | Målgrupp: Tekniska programmerare | Förkunskaper: Praktiska kunskaper i något kompilerande språk
https://www.ribomation.se/programmerings-kurser/c-programming-grundkurs/

Trots att språket C skapades i början på 70-talet är det fortfarande det naturliga 
valet vid maskinnära programmering. Denna kurs lär dig allt du behöver veta för 
att komma igång och bli produktiv med programmering i C oavsett om målsystemet är 
en Arduino, Raspberry PI eller en vanlig PC.

I denna grundkurs om programspråket C får du lära dig allt du behöver
veta för att kunna omsätta dina nya kunskaper i praktiken direkt efter
kursen.

- Basic syntax in modern C, C11, C17, C23
- Understand and be able to use pointers
- Create linked data types
- Handle text strings securely
- Manage text files
- Build C applications
- Create and link library files
- Debug C program
- Look for memory leaks
- Manage binary block-divided files
- Manage dates and times and format them

#### Background and Overview
* The language B
* Why C was invented
* Kernighan & Ritchie C (K&R C)
* ANSI C
* C89
* C99
* C11
* C17
* C23
* Language properties
* Overview of the syntax

#### Scalar Types
* Integral types
* Floating-point types
* Boolean values
* Characters
* Type variations, such as short/long, signed/unsigned
* Variables
* The sizeof operator
* Scopes

#### Operators
* Arithmetic operators
* Relational operators
* Logical operators
* Assignment expression operators
* Increment & decrement operators
* Type alias
* Type casts
* The address operator
* Printing to the console
* Reading from the console

#### Composite Types
* Structs
* Unions
* Arrays
* Text strings

#### Statements
* If statements
* While loops
* For loops
* Foreach loops
* Switch statements

#### Functions
* Function syntax
* Specification vs. implementation
* Function main()
* Understanding exit codes
* Command-line arguments
* Global vs. local data
* Usage of static variables and their meaning
* Inline functions

#### Understanding Pointers
* What is a pointer
* Pointer declaration syntax
* The dereferencing operator
* Starred pointers
* Pointer arithmetics
* Array access
* Why arrays and pointers are the same
* Text strings are arrays of characters
* Struct access
* Understanding the address operator
* Pointer to a function
* Indirect function calls

#### Standard Library
* Overview
* Online documentation

#### Dynamic Memory Blocks
* What is dynamic memory
* Using `malloc()` and `free()`
* Why `calloc()` is better than `malloc()`
* Using `realloc()`
* Understanding briefly the structure of the system heap
* Memory block manipulating functions
* Linked list data-types
* Binary-tree data-types
* Allocating data on the call-stack using `alloca()`

#### Working with Text String
* Understanding that string literals are read-only
* Overview of string manipulating functions in the standard library
* Character oriented functions
* String oriented functions
* Conversion functions
* Allocating memory blocks for strings
* Copying strings
* Searching strings
* Tokenization of strings

#### Working with Files
* Opening files
* File opening modes
* Formatted writing
* Formatted reading
* Changing the read/write position in a file
* Line-oriented reading
* Byte-oriented read/write

#### Designing Data-Structures in C
* Basic principle
* Applying the style of "object-oriented C"
* Initialization vs. object creation
* Dealing with object destruction
* Header files vs. implementation files
* Creating static libraries

#### The Pre-Processor
* Including application files
* Including system files
* Constants
* Pre-defined constants
* Function macros
* Conditional compilation
* Include guards
* Stringification
* Name concatenation
* Variadic macros
* Assertions

#### Machine-Level Support
* Bit-oriented operators
* Shift operators
* Bit-field structs
* Inline ASM (assembler) code

#### Working with Date & Times
* The UNIX Epoc
* Timestamps
* Using struct tm
* Getting the current time
* Formatting date and time values

#### Concurrency Support
* Brief about POSIX Threads
* Concurrency types in functions in C11
* Creating threads
* Waiting for thread termination
* Using mutex locks
* Using condition variables
* Using thread-local storage

#### Building C Applications
* Program organization
* Understanding compilation units
* Compilation steps
* Useful GCC compiler options
* Dynamic vs. static linkage
* Creating static linked library file (*.a)
* Creating dynamic linked library file (*.so)

#### Dealing with Errors
* Compiling for a debugger
* Debugging inside CLion
* Brief about the command-line debugger GDB
* Finding memory-leaks using Valgrind

#### Unit Testing
* What is unit testing
* Installing cUnit
* Writing tests
* Compiling and linking tests
* Executing tests
* Brief about using Catch2 för testing C applications
