Midterm Logistics
The midterm will be a written exam held on Monday October 27th from 5:30 PM to 6:20 PM in Smith Hall 120.
If you absolutely cannot make the scheduled time for the exam, let your instructors know as soon as possible in a private Ed post.
Midterm Policy
The midterm will be a written exam. The exam will be closed book, except that you may have one 5x8 (or smaller) index card with whatever notes you wish written on both sides for reference. The notes must be hand-written, i.e., no computer printouts, no scanned/reduced notes, and no electronic devices or other technology.
You should understand the ideas and core concepts and how to use them, but don't memorize API details. We'll provide hints or reference material on the exam for API details as needed, but you should know the basics.
If you absolutely cannot make the scheduled time for the exam, let your instructors know as soon as possible in a private Ed post.
Midterm Topics
The midterm will cover content up through (and including) C++ templates. Knowledge of topics covered after that will not be expected in the exam.
- 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)
- More tools: basics of using git for version control
(add/commit/push, primarily), what to put in a repository and what
to leave out
- More tools: be able to read and interpret basic valgrind output
and use it to identify memory bugs in programs
- C language and program execution
- Review: standard types, operators, functions, scope, parameters,
strings, etc.
- Extended integer types (int32_t, uint64_t, etc.) and when to use them
- Standard I/O library and streams: stdin, stdout, fopen, fread,
scanf, printf, fwrite, etc.
- POSIX libraries – wrappers for system calls
- POSIX-layer I/O: open, read, write, etc.;
basics of directory reading API
- Relationship between C standard library, POSIX library
functions, and system calls
- Error handling - error codes and errno; error handling/retry for POSIX read/write
- 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; stack frames
- Function parameters
- Call by value semantics (including structs, pointers)
- Arrays as parameters - pointers
- Using pointers to approximate 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 *(a+i)
- 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.
- Data structures and operations from the course projects (hw1, hw2)
(copies of header files will be provided as needed if the exam includes specific
questions about project code)
- C++
- Classes and modularity, namespaces
- Be able to read and create 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 executed
- Know what a destructor is and when it gets executed and what it
should do
- 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)
- Templates
- Basics of templates - template parameters for classes and
functions, when templates are expanded with actual types,
templates and header files.