Outline for April 9, 2025
Reading:
zyBook
§2.20, 6.1–6.8
Due:
Homework #1, due April 14, 2024
Review of the CSIF and compiling
Quick review
signed vs. unsigned [
unsigned.c
]
Type casting [
cast.c
]
Overflow and types [
mult.c
]
Increment and decrement [
ppmm.c
]
Functions in C
Parameters: pass (or call) by value [
swap.c
]
Arguments: instantiations of parameters matched in order
Return values
Show the program stack and how it relates to functions
Pointers and indirection
A pointer is an address
Declarations
Address (
&
), dereference (
*
) operators
Indirect references
More on functions in C
Parameters: pass (or call) by reference (also called output parameters)
Example: swap function — exchange values of two variables (
swap.c
)
Pointers and Arrays
Arrays as pointers (pointer constants)
How indexing works
Arrays as function parameters
Multi-dimensional arrays
More on arrays
Initializations
Contrast with pointer initialization
C arrays and strings
String representation: array of chars terminated by NUL (ASCII ‘\0’)
gets(buf)
,
fgets(buf, size, fp)
[
bad.c
,
good.c
]
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email:
mabishop@ucdavis.edu
ECS 36A, Programming & Problem Solving
Version of April 10, 2025 at 8:11AM
You can also obtain a PDF version of this.