To be an expert C programmer you need to master the use of pointers. This course explains pointers in real depth. It explains pointer variables, pointer arithmetic, indirection, memory allocation, how to create and maintain linked lists and how to use function pointers. In fact, by the time you finish this course, you will know pointers inside out. You will understand what they are, how they work and how to make sure that they don’t make your programs crash!
This is not a course for beginners. It is aimed at programmers who already have a good working knowledge of C programming and who need to take the next step in mastering C by gaining a deep understanding of pointers.
If you’ve struggled with pointers  and can’t quite figure out what all those ‘arrow diagrams’ really mean or what exactly is the relationship between pointers and addresses, this is the course for you. In a series of short, tightly-targeted lessons, you will learn all about:Â
The source code for all the example programs is provided, so if you need to try out my code you can load it and run it in your preferred C IDE or code editor.
Who this course is for and what you will get out of it.
What is in the course and how should you study it?
Pointers and addresses - how are they related?
How to create and use a pointer variable in C.
Dereferencing to get at the data that is ‘pointed to’.
What are pointers?
This document contains some brief notes on topics covered in Step One of the course. You may want to refer to use these notes as a revision aid or to help clarify important points from this section.
The address of the array is the same as the address of the first item in the array. Why is that important?
How can pointer values be displayed?
Let’s see how pointers and addresses work – and why arrays are special.
Pointers to pointers
Pointers to pointers to integers
Arrays of arrays of characters
What is **argv in the main() function?
Pointers to void
Setting aside storage space
How to allocate the right amount of memory for a specific amount of data
Why does your C compiler will complain about some functions?
How to clear memory before allocating
How to free memory that is no longer neededÂ
How to change the size of a block of allocated memory
What does it mean when you add 1 to a pointer?
Using pointer arithmetic with arrays
But how much memory does a struct need?
Why the order of fields in a struct is important
Understanding that data types of a certain size are aligned on boundaries of that size
Pointer arithmetic works with complex types as well as simple types
Still confused by pointers? Here I show how to use your debugger to understand indirection
Here’s another example of how to use a debugger with multiple indirection – pointers to pointers to pointers, and see how they are stored in memory
The relationship between pointers, addresses and data stored in memory
This document contains some brief notes on topics covered in Step Two of the course. You may want to refer to use these notes as a revision aid or to help clarify important points from this section.
Limitations of arrays and using linked lists as an alternative
How is a linked list different from an array?
Lists that include one pointer linking each element to the next one
Do you really always need to free memory?
Lists whose elements contain pointers to each adjacent element
An example showing how to create a simple double-linked list
Initializing a doubly-linked list not quite as simple as initializing a singly-linked list
A sample project showing a doubly-linked list
Queues are very common data structures in programming – here I explain what they are
Using a doubly linked list as a queue
A stack is another important type of data structure – here we see how it differs from a queue
You may need pointers with a stack, but you may not need a linked list
Adding and removing items to and from a stack
Iterating over list elements
Making a new copy of an existing queue
How would you delete an item from the middle of a list?
How would you add an item into a list?
What is a function pointer and what are they for?
The strange syntax for declaring a function pointer
How a single piece of code can call different functions using function pointers
Pointers in linked lists, queues and stacksÂ
This document contains some brief notes on topics covered in Step Three of the course. You may want to refer to use these notes as a revision aid or to help clarify important points from this section.