Understanding and Using C Pointers - Embedded.com

Understanding and Using C Pointers

What! An entire book just about pointers?

That was my first reaction when looking at this volume. But Richard Reese’s Understanding and Using C Pointers is actually a pretty good source of information about this critical subject. At times it is a bit repetitive; in other cases I think a more detailed explanation about an example would have been helpful.

C pointers are a sore subject for a lot of people. Much C code is obviously written to avoid them; those developers probably don’t have a deep understanding of the subject. Competent assembly programmers know that a pointer is akin to assembly’s indirection and so they figure that the C version is no big deal. But in C they are far more nuanced than when working at the mnemonic level.

The book is generally well-written and accurate, though a couple of flagrant mistakes were odd, like a comment that you can make a number negative by setting the MSB. Well, yeah, that will be negative but flipping the MSB will probably not yield the desired result.

The subject is completely covered, and not just in isolation. For example, there’s plenty about dynamic memory use, which is, of course, a place where pointers are required.

The chapters give a good sense of the material:

  • Dynamic Memory Management in C
  • Pointers and Functions
  • Pointers and Arrays
  • Pointers and Strings
  • Pointers and Structures
  • Security Issues and the Improper Use of Pointers
  • Odds and Ends

The chapter on security is of less interest than one might think. An experienced C developer will consider the issues identified as boneheaded mistakes. These include things like dangling pointers and the like. Perhaps a novice might find this information other than obvious.

The last chapter talks about memory-mapped peripherals, aliasing, and threads, and has a very good description of callbacks. The author also goes into some OO concepts in detail, showing how to implement polymorphism in C. I’m not sure what the point(er) of that is; you might as well just use C++.

Experts will get little to nothing from the book. Novices will learn a lot; much more than they will get about the subject in any other C book I have read. I’d highly recommend it for them after they learn the rudiments of the language. Those at the intermediate level will surely profit from reading Reese’s book, probably more than they realize.

The book cries out for a set of student exercises. It’s easy to read a three line example and understand the principles. Until one tests one’s knowledge by writing code and struggling to remember needed syntax the lessons won’t be firmly implanted in the brain.

What do you think? Are you proficient with using pointers?

Editor's Note : To learn more about this topic, go to “Getting to the point(ers) about C.”

Jack G. Ganssle is a lecturer and consultant on embedded developmentissues. He conducts seminars on embedded systems and helps companieswith their embedded challenges, and works as an expert witness onembedded issues. Contact him at . His website is.

2 thoughts on “Understanding and Using C Pointers

  1. Jack, Thank you for what appears to be a very honest review. It is unfortunate that far too many product/book reviews end up looking like shill pieces. This certainly does not!

    You ask what the point is of implementing polymorphism in C. It's exactly the

    Log in to Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.