Introduction to C
This course will cover the basics of the C programming language. The student will familiarize themselves with the basic keywords of the language and how to structure code. By the end of the course, each student will have written themselves a calculator to perform basic arithmetic.
Students will work through the following chapters and perform the exercises. Questions may be asked of the mentor as well as the community on IRC.
- What is source code and machine code.
- What is a compiler, linker, and toolchain.
- Structure of a basic C program.
- Compiling with warning flags.
- What is a type?
- Basic arithmetic operators such as -, +, /, and *, ++, --.
- Writing comments.
- More on printf(), introduction to scanf().
- Difference between %d and %lf in format functions.
- What is scope?
- What are code blocks?
- Conditionals with if/else if/else.
- Loops with while and do/while.
- Loops with for.
- Conditionals with switch/case.
- When to use if/else if/else vs switch/case.
- Creating functions.
- static keyword.
- default values (static defaults to 0, etc)
- Separating code into separate file.
- What are Arrays?
- Stack vs Heap.
- What is a string?
- UTF-8 vs ASCII.
- Arrays of strings (GStrv)
- What is a Structs?
- What is a Union?
- Spliting, joining, and manipulating strings.
- Allocating and freeing memory.
- Heap and Stack allocations.
- Bitwise operators
And (&), Or (|), Exclusive Or (^), Ones Complement (~)
Left Shift (<<), Right Shift (>>)
- Bit fields
- Big-endian vs Little-endian
- Host byte order
- Network byte order
- Portable sized types (gint32, gint16, etc)
- Linked lists (GList, GSList).
- Hashtables (GHashTable), hash functions, compare functions.
- Passing functions as parameters
- GArray, GByteArray, and GPointerArray
- Building filenames
- Listing directories.
- Opening, reading, and writing to disk.