Understanding and Using C Pointers: Core Techniques for Memory Management 1st Edition
Use the Amazon App to scan ISBNs and compare prices.
Improve your programming through a solid understanding of C pointers and memory management. With this practical book, you’ll learn how pointers provide the mechanism to dynamically manipulate memory, enhance support for data structures, and enable access to hardware. Author Richard Reese shows you how to use pointers with arrays, strings, structures, and functions, using memory models throughout the book.
Difficult to master, pointers provide C with much flexibility and power—yet few resources are dedicated to this data type. This comprehensive book has the information you need, whether you’re a beginner or an experienced C or C++ programmer or developer.
- Get an introduction to pointers, including the declaration of different pointer types
- Learn about dynamic memory allocation, de-allocation, and alternative memory management techniques
- Use techniques for passing or returning data to and from functions
- Understand the fundamental aspects of arrays as they relate to pointers
- Explore the basics of strings and how pointers are used to support them
- Examine why pointers can be the source of security problems, such as buffer overflow
- Learn several pointer techniques, such as the use of opaque pointers, bounded pointers and, the restrict keyword
Frequently bought together
Customers who viewed this item also viewed
Editorial Reviews
Amazon.com Review
Q&A with Richard Reese, author of "Understanding and Using C Pointers"
Q. Why is your book timely?
A. The C language continues to be a popular and widely used language. In addition, there are millions of lines of C code being maintained. Pointers are central to C and a solid understanding of them is important in crafting reliable and secure software. Understanding C pointers has always been important but they have not always been adequately covered. Their widespread usage in new and old applications begs a complete and comprehensive coverage.
Q. What do you hope that readers of your book will walk away with?
A. I hope that the experienced developer will be able to fill any holes in their understanding of C pointers. I hope that the less experienced developers will become more proficient and confident in their application of pointers.
Q. Can you give us a few tips on using pointers?
- Be careful when using pointers to void. If you cast a pointer to a pointer to void there is nothing preventing you from casting it to a different pointer type.
- When using function pointers the programmer must be careful to ensure it is used properly because C does not check to see if the correct parameters are passed.
- New code development should use the restrict keyword with most pointer declarations. This will enable better code optimization. Modifying existing code may not be worth the effort.
- Compilers do not always do a good job at reporting alias-related warnings. They can sometimes miss aliases and may sometimes report alias problems where they don't exist. It is ultimately up to the programmer to identify alias conditions.
- Remember NULL and NUL are different. NULL is used as a special pointer and is typically defined as ((void*)0). NUL is a char and is defined as '\0'. They should not be used interchangeably.
- Improperly aligned pointers can result in an abnormal program termination or retrieval of bad data. In addition, slower pointer access is possible if the compiler is required to generate additional machine code to compensate for the improper alignment.
About the Author
Richard Reese has worked in the industry and academics for the past 29 years. For 10 years he provided software development support at Lockheed and at one point developed a C based network application. He was a contract instructor providing software training to industry for 5 years. Richard is currently an Associate Professor at Tarleton State University in Stephenville Texas.
Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.
Product details
- Publisher : O'Reilly Media; 1st edition (May 28, 2013)
- Language : English
- Paperback : 226 pages
- ISBN-10 : 1449344186
- ISBN-13 : 978-1449344184
- Item Weight : 13 ounces
- Dimensions : 7 x 0.48 x 9.19 inches
- Best Sellers Rank: #174,348 in Books (See Top 100 in Books)
- #9 in Memory Management Algorithms
- #34 in C Programming Language
- #40 in Microsoft C & C++ Windows Programming
- Customer Reviews:
Customer reviews
Top reviews from the United States
There was a problem filtering reviews right now. Please try again later.
int *pi; // means "pi is a pointer to an int"
It clearly explains the use of the dereference operator in an lvalue:
*pi = 5 // The int 5 is assigned to memory location where pi points.
But it pointed out that this (very similar to the above) is a common error:
int *pi = 5; // We are declaring a pointer to an int, and then trying to assign the integer 5 to the pointer, not the integer memory location.
And that's all just in chapter 1! He helpfully diagrams memory after each use of pointers, making the difference between the stack, heap and the data segment (static memory) clear. There are detailed chapters on pointer use with dynamic memory, functions, arrays, strings, and structures.
It's nice to have an entire book focused entirely on pointers. The focused drill is clearing up confusion that plagued me for longer than I care to admit. Thank you!
A really happy Michael Stolzle,
All too common with math and theoretical CS authors, many or most of whom are professional educators, is the attitude that brevity is beauty. Whether they are interested in instilling their ideas in the reader is not evident from their writing. Reese provides the right level of detail and a coherent exposition which develops a solid intuition without having to re-read his explanations.
The conceptual diagrams are helpful but a little ambiguous in referencing which rectangle is the function stack, which is main, and which is the heap. I hope the author improves the diagrams in his next edition. I do not deduct any stars because this book is much better than anything else, and it covers essential CS material.
Top reviews from other countries
It skips all the other stuff covered by intro books and focuses on the real advantage of using C over other languages (i.e. pointers). I would recommend this book for new programmers or just as a refresher to others (as in my case).








