Understand and Use C Pointers
Understand and Use C Pointers
Understand and Use C Pointers
Many "freshman" programmers do not fully understand or appreciate pointers in the C language.
When I wanted to learn about pointers—variables that contain a memory address—I took a book on
summer vacation and could hardly wait to get back to my PC to try example programs. Pointers were
cool and versatile. Since then I have used pointers infrequently except for a recent project that
requires a function to operate on an array. You don't pass an entire array to a function. Instead you
use a pointer to locate the array and a value to indicate the number of elements. Frankly, I could
program what I needed these days without including pointers in my code, so I hardly gave them a
thought.
You might think, "I deal mainly with code for hardware, so pointers seem unimportant." But you
might need them sometime, and you might need to understand how they work when you encounter
them in another person's code:
Reese, Richard, "Understanding and Using C Pointers," O'Reilly Media, Sebastopol, CA, USA. 2013.
208 pages, paperback. ISBN: 978-1-449-34418-4. List price: $29.99.
Also see:
● A few pointers
● 10 C Language Tips for Hardware Engineers
● Using pointer arrays to map peripherals