A slow introduction to pointers in C
The C11 programming language has a very powerful feature
for addressing and modifying memory which,
for now,
we'll casually term "pointers in C".
- If used correctly pointers
can enable very fast, efficient, execution of C programs.
- If misunderstood or used incorrectly,
pointers can make your programs do very strange, incorrect things,
and result in very hard to diagnose and debug programs.
The primary role of pointers -
to allow a program (at run-time) to access its own memory -
sounds like a useful feature,
but is often described as a very dangerous feature.
There is much written about the power and expressiveness of C's pointers,
with general agreement that C's pointers are a
threshold concept in Computer Science.
(Recently much has been written about Java's lack of pointers.
More precisely,
Java does have pointers,
termed references,
but the references to Java's objects are so consistently and carefully
constrained at both compile- and run-times,
that little information about the run-time environment is exposed
to the running program,
and little can go wrong).
|
Pointers on C,
Kenneth Reek,
Addison-Wesley,
636pp, 1998.
|
Understanding and Using C Pointers,
Richard Reese,
O'Reilly Media,
226pp, 2013.
|
Pointers in C Programming,
Thomas Mailund,
APress,
537pp, 2021.
|
CITS2002 Systems Programming, Lecture 11, p1, 26th August 2024.
|