Introduction to Programming in C
Course objectives
The course teaches the basics of C in the K&R spirit, using a modern dialect of the language. Most work is done in a Linux or WSL terminal (bash). Emphasis is placed on understanding the fundamentals of the language, low-level programming principles, memory management, native data types, and code efficiency.
Requirements for students
Students are expected to participate actively in seminars, complete assignments continuously, and complete a programming project that shall be assigned no later than week 8.
Content
| 1 | Introduction to C and program structure | History of C, its philosophy and use. Working in the terminal. First program "Hello World", compilation and execution. |
| 2 | Number types and operations | Representation of numbers, overflow. |
| 3 | Program flow control | Conditions, switches, loops, signals, command-line arguments. |
| 4 | Functions, pointers, arrays, strings | Defining, declaring, and calling functions. Parameters and return values. Scope of variables. Recursion. Modular program structure. The preprocessor, header files, and conditional compilation. An introduction to the standard C library. |
| 5 | Pointers, arrays, strings | One-dimensional arrays. Relationship between arrays and pointers. Pointer arithmetic. Pointers as function arguments (output parameters). Strings as character arrays. Standard functions for working with strings. |
| 6 | Multidimensional arrays, pointers to functions | Arrays of pointers versus multidimensional arrays. Pointers to functions as a tool for abstraction. Command-line arguments. |
| 7 | Input and output | The standard library header stdio.h. Standard streams (stdin, stdout, stderr). Formatted input and output. Working with files. Chaining input and output using pipes and redirection. |
| 8 | Data structures and memory management | Composite data types. Structure definitions, nested structures, and arrays of structures. Static and dynamic memory allocation. Data lifecycle. Common memory errors (memory leaks, use-after-free errors, and illegal access). |
| 9 | Terminal interface using ncurses | A library for controlling the terminal: windows, keyboard input, and full-screen output. |
| 10 | The C standard library | The headers stdlib.h, string.h, ctype.h, math.h, time.h. Quick sort. Handling errors from library calls. |
| 11 | Calling C from other languages | Writing a Python library in C. Integrating C and C++ code. |
| 12-13 | Presentations of student projects |
Literature
Brian W. Kernighan and Dennis M. Ritchie. The C Programming Language. 2nd ed. Prentice Hall, 1988. archive.org