A. Additional Readings and Resources
The reading for this unit will come primarily from Programming in C, 3rd Edition available to UMass students for free through E-Books at UMass.
01: Course Introduction
Overview and purpose
How Tos:
Log in to edlab
Linux basics: ls, cd, rm, .mkdir/rmdir, cat, man
How to read a man page for a command
Editor: write code, compile it, and run it (demo)
SFTP your code to your own machine (rsync? scp?)
Upload your code to Gradescope
02: C Basics (Reading: 1-4)
How To:
Editor: write code, compile it, and run it
Basic types and declarations
Basic expressions, statements
Expressions
Loop
while / for / do while
Condition
if / switch
Printf
Aligning Output
String constants
Scanf
How To:
How to read a man page for a library function
gcc (typical command lines)
gdb (simple debugging (mention -g))
03: Arrays and Functions (Reading: 5-8)
Array
Array initialization
Matrix
Array length
Array and memory addresses
Function
Function Prototype
Local variable, global variable, and return value
Call stack (conceptual)
Application
Passing arrays to a function
C strings
04: Structures
Structure definition and declaration
Structure initialization
Structures and memory
Application
Copy, copy, copy
Array of Structures
Function and Structures
Structures in a Structure
Arrays in a Structure
Enumerated Types
05: Pointers (Readings: 9-10)
Memory: stack, heap, and addresses (a mental model of memory)s
Maybe, we do not want to copy, copy, copy.
What is a pointer?
How do pointers relate to memory?
Defining a pointer variable
Retrieving a pointer variable
Pointers and strings
Pointers and structures
06: More Pointers (Readings: 11)
Structure type pointers
Structure type self-reference
Forward declarations with typedef
Linked list and pointers
Terminating linked lists
Pointers and parameters/arguments
Pointers and arrays
Pointer arithmetic
07: Dynamic Allocation (Readings: 17, 13)
What is dynamic allocation of memory?
malloc, calloc, sizeof, etc.
free
dangling pointers
C dangers
Linked list example
08: The Preprocessor
(The slides tell it all - I made some minor updates to the slides.)
Position of the preprocessor in the compilation pipeline and its role in the overall process
Basic use of #define and why
#define of expressions
Basic #define macros (i.e., with arguments), and their dangers
#include, particularly for .h files
Conditional compilation and some of its common uses
Use of ## and # in macro bodies for special effects
09: String-oriented File Input/Output
String-oriented formatted I/O: printf, scanf, overview of format specifiers
stdin, stdout, stderr + fprintf, fscanf (sprintf, sscanf?)
getchar, putchar, getline
fopen, fclose, getc, putc, fgets, fputs
File-level operations: rename, remove, (create?)
10: Program Inputs
Command line arguments
argv, argc, envp, getenv, putenv
exit
String functions (strchr, strstr, strcpy, strncpy, ..., atoi, ...)
Date functions
11: Number Representation (light)
Why base two?
Basic unsigned base two number system, (conversion to/from decimal?)
Octal and hexadecimal
Sign-magnitude and its problems
One's complement and its problems
Two's complement for integers of a given size
C char, short, int, long long int, etc.
The bit-string view
Bit-wise operations (shifting, too)
Idea of flags and fields, recipes/idioms for accessing/updating
Floating point representation (overview)
Normal IEEE floats
Subnormal numbers
NaNs
12: Larger Programs (Readings: 15-16)
Interface vs implementation ~~ .h file vs .c file
How to present things declared in one module for use in another, etc. (separate compilation)
static, extern
linking process
Makefiles: automating the build process
Rules and recipes, notion of built-in recipes
Notion of dependencies (advanced concept: getting dependencies from gcc)
Make variables as useful shorthands, and way to adjust effect of built-in recipes
Some conventional targets (all, clean, ...)