Lesson 6: Some Helpful Pointers
Outline:
- Recap: C string functions
- questions from the lab?
- example:
strings.c
- Program memory
sizeof- example:
sizes.c(includestypedefexample) - memory organization
- allocating stack and heap memory
- Pointers
- variable addresses
*versus&- arrays and pointers
- example:
pointers.c
- variable addresses
- Assignment 3: String Things
- data store: practice with structs and
chararrays - string splitter: use
strtok– see documentation for an example
- data store: practice with structs and
Want additional practice?
Check out the interactive exercises from the textbook!
Reminder: next quiz Monday
You will see these Quiz Learning Objectives:
- DR 1: UTF-8 encoding
- DR 2: UTF-8 decoding
- DR 3: struct layout
- DR 4: array layout
- DR 5: C strings
There likely won’t be any additional questions, but my first choice would probably be NR 1 or NR 2 if it ends up faster/shorter than I expect.
Reading assignment (to be completed by the next class):
What we talked about today:
- DiS Sec. 2.1: Parts of Program Memory and Scope
- DiS Sec. 2.2: C Pointer Variables
- Binky Pointer Fun Video C (video by Nick Parlante)
- Pointer basics (Stanford)
- Take a look at The 5-Minute Guide to C Pointers by Dennis Kubes. If you don’t read this now, return to it in a few days. Some of it won’t make sense until later this term, but it’s still valuable.
Reviewing more in-depth:
For next time:
- Assignment 3: String Things – read the assignment description and try to run the starter code!
- DiS Sec. 2.3: Pointers and Functions
- DiS Sec. 2.4: Dynamic Memory Allocation