What is an array of pointers?

This is a recommends products dialog
Top Suggestions
Starting at
View All >
Language
French
English
ไทย
German
繁體中文
Country
Hi
All
Sign In / Create Account
language Selector,${0} is Selected
Join & Shop in Lenovo Pro
Register at Education Store
Pro Tier Benefits
• Save up to an extra 5% on Think everyday pricing
• Purchase up to 10 systems per order (5 more than Lenovo.com)
• Spend $10K, advance to Plus Tier with increased benefits
Plus Tier Benefits
• Save up to an extra 8% on Think everyday pricing
• Purchase up to 25 systems per order (20 more than Lenovo.com)
• Spend $50K, advance for free to Elite Tier with increased benefits
• Take advantage of flexible payment options with TruScale Device as a Service. Learn More >
Elite Tier Benefits
• Save up to an extra 10% on Think everyday pricing
• Purchase up to 50 systems per order (45 more than Lenovo.com)
• Take advantage of flexible payment options with TruScale Device as a Service. Learn More >
Partner Benefits
• Access to Lenovo's full product portfolio
• Configure and Purchase at prices better than Lenovo.com
View All Details >
more to reach
PRO Plus
PRO Elite
Congratulations, you have reached Elite Status!
Pro for Business
Delete iconRemove iconAdd iconReload icon
TEMPORARILY UNAVAILABLE
DISCONTINUED
Temporary Unavailable
Cooming Soon!
. Additional units will be charged at the non-eCoupon price. Purchase additional now
We're sorry, the maximum quantity you are able to buy at this amazing eCoupon price is
Sign in or Create an Account to Save Your Cart!
Sign in or Create an Account to Join Rewards
View Cart
Your cart is empty! Don’t miss out on the latest products and savings — find your next favorite laptop, PC, or accessory today.
Remove
item(s) in cart
Some items in your cart are no longer available. Please visit cart for more details.
has been deleted
Please review your cart as items have changed.
of
Contains Add-ons
Subtotal
Proceed to Checkout
Yes
No
Popular Searches
What are you looking for today ?
Trending
Recent Searches
Hamburger Menu
Use Enter key to expand
EnglishCreated with Sketch.
EnglishFrench
  • Lenovo Pro Business Store

    Join  Lenovo Pro Business Store

    Created with Sketch.
    Lenovo Pro Business Store

    Log In / Sign Up

    Learn More

  • Accessibility
    AccessibilityAccessibility
    Accessibility
  • Contact Us
    Contact UsContact Us
    Contact Us

    Sales:

    Home:

    1-855-253-6686 Option #2

    Business:

    1-866-426-0911

    Chat Now >

    Visit Sales Support Page >


    Order Support:

    Order Lookup >

    Visit Order Support Page >

    Technical Support >

Lenovo
skip to main content
All
  • All
  • Laptops
  • Desktops
  • Workstations
  • Monitors
  • PC Accessories & Electronics
  • Tablets
  • Servers & Storage
  • Servers Accessories
  • Account
    Sign In / Create Account
    Account
    My Lenovo Account
    Keep track of your wishlist, orders, and rewards all in one place
    Sign In / Create Account
    Welcome Back!
    Access your order, subscriptions, saved carts, rewards balance, and profile
    View My Account
    Orders
    View & track your orders
    Rewards
    Earn & redeem Rewards
    Profile
    Edit name, password, and account settings
    Wishlist
    Manage a wishlist of your favorite products
    Products
    Manage your devices, accessories
    Product Registration
    Register your product and/or update your warranty dates
    Lenovo Family Hub
    Manage your family's orders all in one place
    Sign Out
  • My Lenovo Rewards
    My Lenovo RewardsMy Lenovo Rewards
    My Lenovo Rewards
  • Cart
    CartCart
    Cart
  • Products
  • Solutions
  • Services
  • Support
  • About Lenovo
  • Deals
  • Business
  • Student
  • Gaming
  • Laptops

  • Desktops

  • Workstations

  • Accessories
  • Software
  • Monitors
  • Tablets

  • Servers & Storage
  • AI
  • Deals
  • Ultimate Summer Savings! Get the tech you want at prices you'll love + Buy more, Save More Shop Now >

  • Win $1,000 in Rewards! Join or sign in to My Lenovo Rewards and spend $1,000+ for a chance to win $1,000 in rewards— Free entry also available, no extra steps needed! Terms apply. Ends 6/29 Join for Free >

  • Business Financing Available. Split payments from 4 to 52 weeks, options as low as 0% interest. See Details >

  • Shopping for a business? New Lenovo Pro members get $100 off first order of $1,000+, exclusive savings & 1:1 tech support. Learn More >

  • Build your laptop today & save big! Choose your Yoga >

Home > Glossary > What is an array of pointers?
Glossary Hero    
Learn More    
StarStar

Annual Sale

Lenovo Laptop SaleLenovo Laptop Sale

Laptop Deals

Desktop DealsDesktop Deals

Desktop Deals

Workstation DealsWorkstation Deals

Workstation Deals

ControllerController

Gaming PC & Accessory Deals

MouseMouse

PC Accessories & Electronics Deals

MonitorMonitor

Monitor Deals

Tablet and phoneTablet and phone

Tablets Deals

ServerServer

Server & Storage Deals

Discount tagDiscount tag

Clearance Sale


What is an array of pointers?

An array of pointers is a data structure in which the elements of the array are pointers. Instead of holding data directly, each element in the array holds the memory address (pointer) of another data element. This allows for the creation of an array where each element can point to a different location in memory, typically pointing to other variables or data structures. It allows you to manage multiple memory locations through one array, and it's commonly used in languages like C and C++.

How do I declare an array of pointers?

To declare an array of pointers, you'd specify the pointer type first, followed by the array name and its size. In C or C++, you might do something like int *arr[5];, which declares an array of 5 pointers to integers.

Can I initialize an array of pointers at the time of declaration?

Yes, you can initialize an array of pointers at the time of declaration. For example, you could write int *arr[] = {&x, &y, &z}; where x, y, z are integers already declared in your code. This will store the addresses of x, y, z in the array.

What are the common use-cases for arrays of pointers?

Arrays of pointers are particularly useful when you're working with strings, dynamic memory allocation, or when you want to create an array of different-sized arrays. They're also handy for function pointers, allowing you to call different functions through your array elements.

Does the array size have to be fixed?

In languages like C and C++, the size of the array should be fixed at compile-time unless you're dealing with dynamic memory allocation. However, in some modern languages, arrays can be dynamically resized, but those aren't technically arrays of pointers in the C/C++ sense.

How do I access the values pointed to by the pointers in the array?

To access the values pointed to by the pointers in an array, you'd first use the array index to access the pointer, and then the dereference operator to get the value. In C/C++, *arr[2] would get you the value pointed to by the third pointer in the array arr.

Can I have an array of pointers to arrays?

Yes, you can have an array of pointers to arrays. In this setup, each pointer in the array points to the first element of another array. It's a way to create a jagged array where the "rows" can have different lengths.

Could arrays of pointers be multidimensional?

Absolutely, you can have a multidimensional array of pointers. This gets a bit complex to visualize, but think of it as an array of arrays, where each inner array is itself an array of pointers. You'd use multiple square brackets to access elements, like arr[2][3].

When would it be beneficial to use an array of pointers instead of a regular array?

When you have elements of different sizes or types, an array of pointers is advantageous. Also, if you're pointing to large data structures, it can be more memory-efficient to store pointers rather than the structures themselves.

How do I sort an array of pointers?

You can sort an array of pointers just like a regular array, but you'd be sorting the addresses they point to, not the values. If you want to sort by the pointed-to values, you'll need to dereference the pointers during your comparison in your sorting algorithm.

Can arrays of pointers be used with structs?

Yes, arrays of pointers can point to structs. It's commonly done when you have an array of complex data types. You can then access the struct members through the pointers, like arr[i]->member.

How do I free the memory allocated to an array of pointers?

If you've dynamically allocated memory that the pointers in your array point to, you'll need to loop through the array and use free() for each pointer in C or delete in C++. After that, you can free the array itself if it's also dynamically allocated.

Is it possible to have an array of function pointers?

Absolutely, an array of function pointers is a neat way to call different functions via array indexing. Each element in the array will point to a function, and you can call it using the array index and parentheses, like arr[2](args).

How do I pass an array of pointers to a function?

To pass an array of pointers to a function, you define the function parameter to match the type and size (optional) of the array. In C/C++, a function to accept an array of pointers to integers could look like void myFunction(int *arr[], int size).

What happens if a pointer in my array points to invalid memory?

If a pointer in your array points to invalid memory, accessing it will result in undefined behavior, which could range from your program crashing to subtle bugs. Always make sure your pointers are initialized and point to valid memory locations.

How do I traverse an array of pointers?

Traversing an array of pointers is similar to navigating a regular array; you'd typically use a loop. The difference is in how you access the values. When you reach each pointer, you'd dereference it to get the value it points to. This allows you to perform operations on the actual data instead of the memory addresses. If you're pointing to complex types like structures or objects, you can access their members directly through the pointer, streamlining the process.

Is it more efficient to use an array of pointers rather than an array of objects?

Efficiency depends on the use-case. An array of pointers can save memory if the objects you're working with are large and only a few are accessed frequently. Rather than storing full copies, you store addresses, which are typically much smaller. On the downside, dereferencing pointers has its own overhead, and managing the pointers can be complex. If you're dealing with small, simple objects and need fast, direct access, a regular array might be more efficient.

What are the risks associated with using arrays of pointers?

Arrays of pointers introduce a level of indirection, which, while powerful, can also be risky. Uninitialized pointers can lead to undefined behavior. Also, if you're not careful with memory management, especially in languages like C and C++, you risk memory leaks or double freeing, both of which can result in crashes or bugs. You have to be quite meticulous in managing both the array and the memory to which each pointer points.

Looking for a Great Deal?
Shop Lenovo.com for great deals on A+ Education PCs, Accessories, Bundles and more.
Shop Deals Now

Recommended Education Products

  • Legion 7i Gen 9 (16″ Intel) Gaming Laptop
    Starting at
    $2,179.99
    Learn More
  • ThinkPad X9 15 Aura Edition (15ʺ Intel) Laptop
    Starting at
    $2,259.00
    Learn More
  • Yoga 9i 2-in-1 Aura Edition (14″ Intel) Laptop
    Starting at
    $1,736.99
    Learn More
  • IdeaPad Pro 5 (16” AMD) Laptop
    Starting at
    $1,214.99
    Learn More
  • ThinkPad P1 Gen 7 (16″ Intel) Mobile Workstation
    Starting at
    $2,724.71
    Learn More
  • Shop
    • Student Deals
    • K-12 Student Laptops
    • Student Accessories
    • Laptops by Major
    Education resource
    Explore
    • What is STEM?
    • Best Laptops for College
    • Student & Teacher Discounts
    • Lenovo Sustainability Programs
    Education carry case

    Stem Articles
    See All STEM Articles
    • Online STEM Education

    • STEM Career Tips & Resources

    • Women in STEM

    • STEM Educator Training

    • STEM Grants & Funding

    • STEM Education: Coding for Kids

    • STEM Education: Robotics

    • STEM Education: Biotechnology

    • STEM Education: Sustainability

    • STEM Education: AI & ML

    While every effort has been made to ensure accuracy, this glossary is provided for reference purposes only and may contain errors or inaccuracies. It serves as a general resource for understanding commonly used terms and concepts. For precise information or assistance regarding our products, we recommend visiting our dedicated support site, where our team is readily available to address any questions or concerns you may have.

    Why Lenovo?

    Go Greener with Leno...

    Lenovo is committed to Smarter Climate Action with lower energy laptops, use of sustainable materials and packaging, and available CO2 Offset Services.
    Learn More
    pastel background

    Get It Now, Pay For ...

    Lenovo has multiple financing option: the Lenovo Credit Card, installment plans, and lease-to-own financing op...
    Learn More
    pastel background

    Productivity & Peace of Mind

    Stay productive with Premium Care Plus - 24/7 priority support and coverage against accidental damage. Power through your day with our Smart Performance and extended battery solutions.
    Learn More
    pastel background

    My Lenovo Rewards

    Get up to 9% back in Rewards credit on all purchases! Join or Sign In to start earning today.
    Learn More
    pastel background

    Assistance and Suppo...

    Chat with a trained professional who can help you find the right products, place or check on an order, or setup your Education laptop.
    Contact Us
    pastel background
    Enter email to receive Lenovo marketing and promotional emails. Review our Privacy Statement for more details.
    Please enter the correct email address!
    Email address is required
    • Facebook
    • Twitter
    • Youtube
    • Pinterest
    • TikTok
    • instagram
    Select Country / Region:
    Country
    AndroidIOS

    About Lenovo

    • Our Company
    • News
    • Investors Relations
    • Compliance
    • ESG
    • Product Recycling
    • Product Security
    • Product Recalls
    • Executive Briefing Center
    • Lenovo Cares
    • Careers
    • Formula 1 Partnership

    Products & Services

    • Laptops & Ultrabooks
    • Smarter AI for You
    • Desktop Computers
    • Workstations
    • Gaming
    • Tablets & Smart Devices
    • Servers, Storage, & Networking
    • Accessories & Software
    • Services & Warranty
    • Product FAQs
    • Deals
    • Lenovo Coupons
    • Preconfigured Products

    Shop By Industry

    • Small Business Solutions
    • Large Enterprise Solutions
    • Healthcare Solutions
    • Higher Education Solutions
    • Education Discounts
    • Discount Programs

    Resources

    • Lenovo Pro for Business
    • My Lenovo Rewards
    • Lenovo Financing
    • Customer Discounts
    • Affiliate Program
    • Affinity Program
    • Employee Purchase Program
    • Lenovo Partner Hub
    • Laptop Buying Guide
    • Where to Buy
    • Glossary

    Customer Support

    • Contact Us
    • Shopping Help
    • Return Policy
    • Shipping Information
    • Track my Order
    • Register a Product
    • Replacement Parts
    • Technical Support
    • Forums
    • Provide Feedback
    © 2025 Lenovo. All rights reserved.
    PrivacySite MapTerms of UseExternal Submission PolicySales terms and conditionsAnti-Slavery and Human Trafficking Statement
    Compare  ()
    x
    Call

    Need Help? Call: 

    1-855-253-6686 Option #2

    Select Your Store

    Add items to your Lenovo Pro cart?
    We've noticed that you've entered a different store. Do you want to add these items to your cart in the Lenovo Pro Store?
    No Yes. Add in Lenovo Pro