CSE 333 13sp Midterm Topics

This list is a summary of the topics we've covered in class so far that could potentially be on the midterm. Generally, if you've kept up with everything that's been covered in lecture, sections, exercises, and homework assignments you should be well prepared. A good way to study is to work some of the practice exercises at the end of most lectures if you haven't done them already.

General program organization and where C fits in the ecosystem

  • System layers: C language, libraries, and operating system
  • General workflow needed to build a program – preprocessor, compile, link
  • Preprocessor – how #include, #define, #ifndef and other basic commands rewrite the program
  • Structure of C/C++ programs: header files, source files
    • Declarations vs definitions
    • Organization and use of header files, including #ifndef guards
    • Faking modularity in C – headers, implementations
    • Internal vs external linkage; use of static for internal linkage
    • Dependencies – what needs to be recompiled when something changes (dependency graph behind make and similar tools)
    • Make and makefile basics – how build dependencies are encoded in makefile rules

C language and program execution

  • Review: standard types, operators, functions, scope, parameters, strings, etc.
  • Extended integer types (int32_t, uint64_t)
  • Standard I/O library and streams: stdin, stdout, fopen, fread, scanf, printf, etc.
  • POSIX libraries – wrappers for system calls
    • POSIX-layer I/O: open, read, write, etc.
    • Relationship between C standard library, POSIX library functions, and system calls
  • Error handling - error codes and errno
  • Process address space and memory map (code, static data, heap, stack)
    • Object lifetimes: static, automatic, dynamic (heap)
    • Stack and function calls – what happens during function call, return
  • Function parameters
    • Call by value semantics (including structs, pointers)
    • Arrays as parameters - pointers
    • Using pointers for call-by-reference semantics
    • Function pointers as parameters
  • Pointers, pointers, pointers - &, *, and all that
    • Typing rules and pointer arithmetic (what does p+1 mean?)
    • Relationship between pointers and arrays, a[i] and pointer arithmetic
    • String constants, arrays of characters, C string library
    • Using void* as a “generic” pointer type
    • Casting
    • Dynamic allocation (malloc, free)
    • Potential bugs – memory leaks, dangling pointers (including returning pointers to local data), etc.
    • Be able to draw and read diagrams showing storage and pointers, and be able to trace code that manipulates these things.
  • Structs – how to define and use, meaning of p->x  ( = (*p).x ), structs as local variables, parameters, and return values (value semantics) vs. heap-allocated structs, struct values vs pointers to structs
  • Typedef – how to define and use
  • Linked data structures in C – linked lists, hash tables, etc.

C++

  • Classes and modularity, namespaces
    • Be able to read simple class definitions and add to them, implement functions, trace code, etc.
    • Know the difference between constructors, copy constructors, and assignment and when these are called
    • Know what a destructor is and when it gets called
  • Other basic differences from C
    • Simpler, type-safe stream I/O (cout, cin, << and >>)
    • Type-safe memory management (new, delete, delete[])
    • References – particularly reference parameters
    • More pervasive use of const (const data and parameters, const member functions)
For the midterm, it's okay to skip templates, STL, smart pointers, inheritance, virtual functions, C++-style casts, and other C++ issues. We'll see them later in the course and on the final exam.