Introduction
Dangling pointers in C – Usage and how to prevent them. Great guide for C newbies and Embedded systems programmers. Tutorial with practical examples.
Dangling pointers are those that do not point to valid objects. Pointers are like sharp knives that have tremendous power in C programming. When used properly, they reduce the complexity of the programs to a great extent. But when not used properly, they result in adverse effects and, in the worst case scenario, may crash the system. In this article, focus is given on dangling pointers and what causes them by looking at several different situations in which they occur. I also suggest simple methods to avoid them.
As embedded systems programmer we often get into issues with pointers, we hope this simple tutorial will give you practical insights. This was published in Open Source For U (OSFY) March 2015, authored by one of our mentors.
Below URL is to download the PDF version of the article (dangling_pointers_in_c.pdf), let us know what you think about this tutorial.