Lab 09 -- C Programming - Files, GDB, Valgrind, Linked lists
This page gives an overview of the lecture and the lab session on Sep 25, 2025.
Short lecture summary
-
Dynamic memory allocation for two dimensional arrays and freeing memory.
-
File handling. Opening, reading, writing, closing files.
-
Buffering of
stdout
and the need for use of debugging tools - GDB. Demo for GDB usage. GDB reference card - for a quick summary of options. -
Detecting memory leaks using valgrind. Demo for valgrind usage. Valgrind reference card - for a quick usage summary.
-
Singly and Doubly linked lists. Head of a linked list. Insert and delete operations.
Readings
-
Peter Jay’s GNU Debugger write-up
An excellent and in-depth write up on how to get the most out of GDB.
Read Chapter
-
C Programming A Modern Approach (2nd Ed) by K. N. King (Online version)
Read chapters
-
Dive Into Systems by Suzanne J. Matthews, Tia Newhall, Kevin C. Webb (Online version)
Read chapters
-
Using Valgrind and interpreting the error messages, see this write-up.
Practise
-
Work out the problems in this tutorial on GDB.
-
A tutorial on valgrind usage with an explanation of its output.
Additional readings
-
Guide to debugging with Valgrind.