Understand the C language properly.
Stop guessing while coding.
Clear up the confusion about stdin / stdout / buffers.
- Preprocessing
- Compilation
- Linking
-
.hvs.c -
staticvsextern
Nothing here yet.
A good first exercise is to take one of the .c / .h pairs in 03-pointers
and run it through gcc -E, gcc -S, gcc -c and the linker by hand, looking
at the output of each stage.
- Integer sizes
- Signed vs unsigned
-
charas a number - Endianness
Nothing here yet.
Write a program that prints sizeof for every integer type, and one that detects
the machine's endianness by casting an int* to a char*.
- Pointer basics
- Pointer arithmetic
- Pointers to arrays
- Pointers to structs
- Double pointers
- Function pointers
swap-ints.c, swap-strings.c, double-pointer-allocate.c and
array-of-struct-pointers.c have no main, so they compile but do not link on
their own.
Write a driver for each, then build it with
make run FILE=driver.c EXTRA="swap-ints.c".
- Char arrays
- Null termination
- Stack vs heap strings
- String literals vs allocated strings
- stdin, stdout, stderr
- Buffered vs unbuffered I/O
- Why
printfsometimes does not print (seestdout-buffering-fflush.c) - Why
scanfsucks (seescanf-string.candscanf-multiple-types.c)
- typedef
- Nested structs
- Alignment and padding
- Unions and tagged unions
- Enumerations
The must-do list for this phase. Nothing written yet.
- Reverse a string without library functions
- Implement
strlen,strcmp,strcpy,strcat - Build a small calculator using functions and a struct
- Debug 5 segfaults using gdb
- Visualise stack and heap memory for 10 small programs