Lecture 3: C and gdb

Preparation

Read K&R:

Chapter 2. Types, Operators, and Expressions

2.9 Bitwise Operator

Chapter 5. Pointers and Arrays

5.1 Pointers and Addresses

5.2 Pointers and Function Arguments

5.3 Pointers and Arrays

There is one difference between an array name and a pointer that must be kept in mind.
A pointer is a variable, so pa = a and pa++ are legal.
But an array name is not a variable; construction like a = pa and a++ are illegal.

5.4 Adress Arithmetic

The behavior is undefined for arithmetic or comparisons with pointers that do not point to members of the same array.
(There is one exception: the address of first element past the end of an array can be used in pointer arithmetic.)

5.5 Character Pointers and Functions

Chapter 6. Structures

6.4 Pointers to Structures

(以上是我阅读这几节时划了线的内容)

Handouts

gdb

介绍了下 gdb

pointers example

介绍了下指针

Lab 2: Memory management

to be continued…