Introduction to C
Mentor |
|
Course Materials |
|
IRC |
irc.gimp.net #gnome-university |
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.
Chapter 1
Topics
- 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?
Material
Chapter 1.pdf (click on "View Raw" to download)
Chapter 2
Topics
- Basic arithmetic operators such as -, +, /, and *, ++, --.
- Writing comments.
- More on printf(), introduction to scanf().
- Difference between %d and %lf in format functions.
Chapter 3
Topics
- What is scope?
- What are code blocks?
- Conditionals with if/else if/else.
Chapter 4
Topics
- Loops with while and do/while.
- Loops with for.
Chapter 5
Topics
- Conditionals with switch/case.
- When to use if/else if/else vs switch/case.
Chapter 6
Topics
- Creating functions.
- static keyword.
- default values (static defaults to 0, etc)
Chapter 7
Topics
- Enumerations
- Headers
- Preprocessor
- Separating code into separate file.
Chapter 8
Topics
- What are Arrays?
- Stack vs Heap.
- What is a string?
- UTF-8 vs ASCII.
- Arrays of strings (GStrv)
Chapter 9
Topics
- What is a Structs?
- What is a Union?
- Spliting, joining, and manipulating strings.
Chapter 10
Topics
- Pointers.
- Allocating and freeing memory.
- Heap and Stack allocations.
Chapter 11
Topics
- Bitwise operators
And (&), Or (|), Exclusive Or (^), Ones Complement (~)
Left Shift (<<), Right Shift (>>)
- Bit fields
Chapter 12
Topics
- Big-endian vs Little-endian
- Host byte order
- Network byte order
- Portable sized types (gint32, gint16, etc)
Chapter 13
Topics
- Linked lists (GList, GSList).
- Creating
- Iterating
- Freeing
- Hashtables (GHashTable), hash functions, compare functions.
- Passing functions as parameters
- Creating
- Inserting
- Fetching
- Iterating
- GArray, GByteArray, and GPointerArray
Chapter 14
Topics
- Building filenames
- Listing directories.
- Opening, reading, and writing to disk.