0

Handling pointers

Each pointer must be initialized; I suppose it is an error on programmer’s end when they forget to do so. If they don’t want to initialize to some other variable, at least initializing it to NULL would help? Basically when declaring a pointer and you can’t decide at that point that where it should point, then it is safe to assign it a NULL value. As Pujar (2015) states “The most common mistake is using an uninitialized pointer. Pointers can make your system crash and corrupt memory locations if not handled properly. When pointers are incremented or decremented to point to next or previous memory locations, they may be pointing to invalid memory locations which when read or written to may cause serious problems.”

References:

Pujar, R. (2015) Bad pointers and invalid memory access in C. Available at: http://www.raviyp.com/embedded/114-bad-pointers-and-invalid-memory-access-in-c (Accessed: 11 July 2017)

ayesha

Leave a Reply

Your email address will not be published. Required fields are marked *