We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Technology

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What Is an Array of Pointers?

By Eugene P.
Updated: Jan 22, 2024
Views: 5,570
Share

An array of pointers is a standard array data type that holds a sequence of memory addressed to data types as opposed to holding other scalar types such as integers or floating point numbers. By using an array of pointers, a program is able to have an array of nearly any data type, data structure, class or even function. Efficient sorting of an array of pointers also is possible so that, if desired, the addresses can be aligned according to their physical location in computer memory. Some of the complications in using an array of pointers are that the data can be easily corrupted and that the type of data being pointed to needs to be managed internally to prevent memory overflow problems.

Not all programming languages allow an array of pointers as the concept was originally conceived. High-level languages that automate memory management do not use pointers in the same way as lower-level languages, although technically an array of class objects in a high level, object-oriented language is an array of pointers; even so, they cannot be used or manipulated in the same way. In a low-level language, the array will actually hold an integer value that is the direct address of the pointer in the memory heap. In most high-level languages, this functionality is not possible, although alternate paradigms exist.

One of the aspects that makes an array of pointers valuable as a programming tool is that the pointers can reference any type of data available. The pointer is a data type in itself, even though its only purpose is to point toward another data type. This means an array of pointers can actually contain a variety of data types in the same array, although the program would need to have a mechanism to keep track of what each pointer was referencing.

A powerful aspect of pointers is that they can actually point to compiled program code in memory. This allows an array to point to functions, not just data. An array of functions can allow dynamic numerical referencing of code. This can be useful when programming a language interpreter or other type of software that needs to call certain functions based on unpredictable input without the need for large conditional statements such as switch blocks.

Some problems presented by an array of pointer data are the possibility of losing the address, preventing that memory from being freed later, and the chance that an address can be corrupted through an unintentional operation such as addition. Attempts to access an incorrect address could lead to corrupted data being read or, in extreme cases such as a failed initialization, a segmentation fault that could cause the program to terminate unexpectedly. Cautious programming can help to mitigate the possibility of these events.

Share
WiseGeek is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.

Editors' Picks

Discussion Comments
Share
https://www.wise-geek.com/what-is-an-array-of-pointers.htm
Copy this link
WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.

WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.