EPL232: Programming Techniques and Tools

Intermediate & Advanced Programming in C and UNIX

Undergraduate Compulsory Prerequisite: EPL131

Instructor

Photo of Andreas Aristidou

Andreas Aristidou

Office: B113, FST01


Lab Instructor

Photo of Pavlos Antoniou

Pavlos Antoniou

Office: B109, FST01

Course Info

  • Type: Undergraduate (Compulsory)
  • Credits: 7.5 ECTS
  • Prerequisite: EPL131 - Programming Principles I

Lectures

  • Lectures A: Tuesday & Friday, 10:30–12:00 (ΧΩΔ02 #009)
  • Lectures B: Tuesday & Friday, 12:00–13:30 (ΧΩΔ02 #116)
  • Recitations A: Wednesday, 12:00–13:00 (ΧΩΔ02 #007)
  • Recitations B: Wednesday, 13:00–14:00 (ΧΩΔ02 #008)

Labs

  • Laboratory: Friday, 17:00–18:30 (ΘΕΕ01 #Β121)

Overview

This course aims to accompany the student in the transition from simple scripting languages to modern system programming, by reviewing basic imperative programming techniques and using them in the ANSI C programming language. To this aim, we first briefly review fundamental programming principles and techniques (such as expressions, declarations, statements and control structures, recursion, etc), and we become familiar with the standard design tools for programs.

We first implement small programs in C in simple areas. We gradually define functions and data structures that are used for writing medium-size programs. In particular, in the first part of the course the student will learn how to write programs in C, using the data types and control structures of C. Then, we discuss the implementation of C programs in the UNIX environment. The student will first learn how to use the UNIX shell and tools and then how to write programs in C that call UNIX system functions. Finally, we consider some basic methods for program development and study the tools that UNIX offers to the programmer for managing relatively big programs (e.g., make files, version control systems, etc.).

Content

  • Introduction to C for Programmers: types x86/x64, loops, selections, expressions, arrays, functions, IO, basic program organization.
  • Advanced C programming constructs: program anatomy and processes, memory and addresses (pointers, pointers and arrays, strings and examples), structures, unions and enumerations. Linear and non-linear programming data structures (dynamic memory allocation, lists, queues, doubly-linked lists, trees, applications and examples).
  • Advanced Compilation Topics and Tools: preprocessor directives, compiling multiple files with makefiles, static (.a) and dynamic (.so) linking of object files (.o), error handling (assert.h), static and dynamic code analysis (valgrind and gprof).
  • Low-level programming: binary operators and examples, binary files and hexdump.
  • Basic commands for programmers in the UNIX operating system: file system, redirection and pipes, permissions and basic filters.
Download Syllabus (PDF)

Course Schedule and Lectures

Introduction: Syllabus & Basics C Fundamentals

Course Objectives and Syllabus, C Advantages and Drawbacks, Comparing C with JAVA, First Program, Directives, Functions, Statements, Compiling C Programs with GCC, Native vs. Intermediate Compilation [C/C++/Objective-C vs. JAVA/Android/C#], Basic Data Types, basic comments, x86/x64 data types basics, reserved identifiers.

Fundamentals I: Formatted I/O, Expressions, Selection Statements, Loops Expressions & Loops

The printf() and scanf() functions, Arithmetic Operators, Assignment Operators (lvalues), Incr/Decr Operators, Expression Evaluation (precedence and order), Logical Expressions and _BOOL (C99), if..else, dangling-else, switch ... break, Loops (while, do, for, break, continue, goto).

Fundamentals II: Basic Types, Arrays and Functions Arrays & Functions

Integer, Float, Character Types on x86 and x64 platforms, Type overflow and explanation, Type Conversion (Implicit and Casting), Type Definitions with typedef, The sizeof operator, 1-d arrays and m-d arrays: subscripting, initialization, sizeof.

Program Organization Files & Scope

Local Variables (auto vs. static), External Variables, Blocks {}, Scope, Organizing a C Program, Comments with Documentation Systems (doxygen), Files: fopen, fread, fwrite, examples with srand(), rand() and time(NULL).

Memory I: Pointers Pointers

Pointer Variables: Declaring and Using, Address (&) and Indirection Operators (*), Pointer Assignment (=), Pointer as Arguments, Using const to protect arguments, Pointers as Return Values.

Memory II: Pointers and Arrays Pointer Arithmetic

Pointer Arithmetic (adding, comparing), Pointer Variables and types, Using Pointers for Array Processing, Combining increment (++) and indirect (*) operators, arrays-functions-pointers, pointers and multi-dimensional arrays ((*p)[i]): working with rows, working with columns, sum example in five different ways.

Memory III: Strings, Array of Pointers and Examples Strings

String Literals and Variables, Reading and Writing, Implementing strcpy(), strlen(), strcat(), strcmp(), Arrays of Strings, Command Line Arguments (argc and *argv[]).

Memory IV: Structures, Unions and Enumerations Structures

Structures: Representation, Initialization, Types, Nested Structures and Arrays, Examples, Pointer-to-Structures ((*p).field | p->field), Memory Alignment Issues (__attribute__ ((__packed__))); Unions: Representation, Initialization, Examples and Applications; Enumerations: Representation, Examples and Applications.

Lab Sessions & Materials

Please read the following information carefully!


The laboratory sessions of this course will use Visual Studio Code (VS Code) as the development environment, GCC as the C compiler, and Git/GitHub for version control and assignment management. Students are expected to be familiar with these tools throughout the semester.
Before attending the first lab, please follow the provided development tools guide (especially sections 1, 3 and 5) to install VS Code, GCC, and Git on your computer. Also read this guide on Git best practices for software development and version control that will be used during the course.
In addition, all students should create a GitHub account before the first laboratory session if they do not already have one. GitHub will be used for submitting assignments, sharing code (with the instructor), and collaborating on course projects.
Week Topic Material
1 C Program Structure and Fundamentals (in/out, operators, conditionals, loops, file manipulation) Lab Files
2 Arrays and pointers — Doxygen documentation Lab Files
3 The string.h library Lab Files
4 Quiz 1 Lab Files
5 Dynamic allocation, structs, enums and unions Lab Files
6 Stacks and Queues Lab Files
7 Multiple file organization and Makefiles Lab Files
8 Macros, conditional compilation and linked lists operations Lab Files
9 Dynamic code analysis with Valgrind and gprof Lab Files
10 Binary files, hexdump and low-level programming Lab Files
11 Unix Commands I Lab Files
12 Unix Commands II Lab Files

Assignments

All Assignments will be announced in Moodle. Sign-up using the code handed out in class!

Text Book and Bibliography