How do you create an array of pointers in C?

To create an array of pointers in C, you have one option, you declare:

  type *array[CONST];  /* create CONST number of pointers to type */

With C99+ you can create a Variable Length Array (VLA) of pointers, e.g.

  type *array[var];   /* create var number of pointers to type */

The standard defines both in C11 Standard - 6.7.6.2 Array declarators and discusses subscripting in C11 Standard - 6.5.2.1 Array subscripting.

A short example using an array of pointers, assigning a pointer to each row in a 2D array to an array of pointers to int, e.g.

#include <stdio.h>
#include <stdlib.h>

#define COL 3
#define MAX 5

int main (void) {

    int arr2d[MAX][COL] = {{ 0 }},  /* simple 2D array */
        *arr[MAX] = { NULL },       /* 5 pointers to int */
        i, j, v = 0;

    for (i = 0; i < MAX; i++) {     /* fill 2D array */
        for (j = 0; j < COL; j++)
            arr2d[i][j] = v++;
        arr[i] = arr2d[i];          /* assing row-pointer to arr */
    }

    for (i = 0; i < MAX; i++) {     /* for each pointer */
        for (j = 0; j < COL; j++)   /* output COL ints */
            printf (" %4d", arr[i][j]);
        putchar ('\n');
    }
}

Example Use/Output

$ ./bin/array_ptr2int_vla
    0    1    2
    3    4    5
    6    7    8
    9   10   11
   12   13   14

Another fundamental of C is the pointer-to-pointer, but it is not an "Array", though it is routinely called a "dynamic array" and can be allocated and indexed simulating an array. The distinction between an "Array" and a collection of pointers is that with an Array, all values are guaranteed to be sequential in memory -- there is no such guarantee with a collection of pointers and the memory locations they reference.

So What Does int **arr[CONST] Declare?

In your question you posit a declaration of int** arr[5] = {0xbfjeabfbfe,0x...};, so what does that declare? You are declaring Five of something, but what? You are declaring five pointer-to-pointer-to-int. Can you do that? Sure.

So what do you do with a pointer-to-pointer-to-something? The pointer-to-poitner forms the backbone of dynamically allocated and reallocated collection of types. They are commonly termed "dynamically allocated arrays", but that is somewhat a misnomer, because there is no guarantee that all values will be sequential in memory. You will declare a given number of pointers to each int** in the array. You do not have to allocate an equal number of pointers.

(note: there is no guarantee that the memory pointed to by the pointers will even be sequential, though the pointers themselves will be -- make sure you understand this distinction and what an "Array" guarantees and what pointers don't)

int** arr[5] declares five int**. You are then free to assign any address to you like to each of the five pointers, as long as the type is int**. For example, you will allocate for your pointers with something similar to:

  arr[i] = calloc (ROW, sizeof *arr[i]);  /* allocates ROW number of pointers */

Then you are free to allocate any number of int and assign that address to each pointer, e.g.

  arr[i][j] = calloc (COL, sizeof *arr[i][j]); /* allocates COL ints */

You can then loop over the integers assigning values:

  arr[i][j][k] = v++;

A short example using your int** arr[5] type allocation could be similar to:

#include <stdio.h>
#include <stdlib.h>

#define ROW 3
#define COL ROW
#define MAX 5

int main (void) {

    int **arr[MAX] = { NULL },  /* 5 pointer-to-pointer-to-int */
        i, j, k, v = 0;

    for (i = 0; i < MAX; i++) { /* allocate ROW pointers to each */
        if ((arr[i] = calloc (ROW, sizeof *arr[i])) == NULL) {
            perror ("calloc - pointers");
            return 1;
        }
        for (j = 0; j < ROW; j++) { /* allocate COL ints each pointer */
            if ((arr[i][j] = calloc (COL, sizeof *arr[i][j])) == NULL) {
                perror ("calloc - integers");
                return 1;
            }
            for (k = 0; k < COL; k++)   /* assign values to ints */
                arr[i][j][k] = v++;
        }
    }

    for (i = 0; i < MAX; i++) { /* output each pointer-to-pointer to int */
        printf ("pointer-to-pointer-to-int: %d\n\n", i);
        for (j = 0; j < ROW; j++) {     /* for each allocated pointer */
            for (k = 0; k < COL; k++)   /* output COL ints */
                printf ("  %4d", arr[i][j][k]);
            free (arr[i][j]);   /* free the ints */
            putchar ('\n');
        }
        free (arr[i]);      /* free the pointer */
        putchar ('\n');
    }

    return 0;
}

You have allocated for five simulated 2D arrays assigning the pointer to each to your array of int **arr[5], the output would be:

Example Use/Output

$ ./bin/array_ptr2ptr2int
pointer-to-pointer-to-int: 0

     0     1     2
     3     4     5
     6     7     8

pointer-to-pointer-to-int: 1

     9    10    11
    12    13    14
    15    16    17

pointer-to-pointer-to-int: 2

    18    19    20
    21    22    23
    24    25    26

pointer-to-pointer-to-int: 3

    27    28    29
    30    31    32
    33    34    35

pointer-to-pointer-to-int: 4

    36    37    38
    39    40    41
    42    43    44

Hopefully this has helped with the distinction between an array of pointers, and an array of pointers-to-pointer and shown how to declare and use each. If you have any further questions, don't hesitate to ask.

Answer from David C. Rankin on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › c language › array-of-pointers-in-c
Array of Pointers in C - GeeksforGeeks
July 23, 2025 - In C, a pointer array is a homogeneous collection of indexed pointer variables that are references to a memory location. It is generally used in C Programming when we want to point at multiple memory locations of a similar data type in our C program.
Top answer
1 of 3
9

How do you create an array of pointers in C?

To create an array of pointers in C, you have one option, you declare:

  type *array[CONST];  /* create CONST number of pointers to type */

With C99+ you can create a Variable Length Array (VLA) of pointers, e.g.

  type *array[var];   /* create var number of pointers to type */

The standard defines both in C11 Standard - 6.7.6.2 Array declarators and discusses subscripting in C11 Standard - 6.5.2.1 Array subscripting.

A short example using an array of pointers, assigning a pointer to each row in a 2D array to an array of pointers to int, e.g.

#include <stdio.h>
#include <stdlib.h>

#define COL 3
#define MAX 5

int main (void) {

    int arr2d[MAX][COL] = {{ 0 }},  /* simple 2D array */
        *arr[MAX] = { NULL },       /* 5 pointers to int */
        i, j, v = 0;

    for (i = 0; i < MAX; i++) {     /* fill 2D array */
        for (j = 0; j < COL; j++)
            arr2d[i][j] = v++;
        arr[i] = arr2d[i];          /* assing row-pointer to arr */
    }

    for (i = 0; i < MAX; i++) {     /* for each pointer */
        for (j = 0; j < COL; j++)   /* output COL ints */
            printf (" %4d", arr[i][j]);
        putchar ('\n');
    }
}

Example Use/Output

$ ./bin/array_ptr2int_vla
    0    1    2
    3    4    5
    6    7    8
    9   10   11
   12   13   14

Another fundamental of C is the pointer-to-pointer, but it is not an "Array", though it is routinely called a "dynamic array" and can be allocated and indexed simulating an array. The distinction between an "Array" and a collection of pointers is that with an Array, all values are guaranteed to be sequential in memory -- there is no such guarantee with a collection of pointers and the memory locations they reference.

So What Does int **arr[CONST] Declare?

In your question you posit a declaration of int** arr[5] = {0xbfjeabfbfe,0x...};, so what does that declare? You are declaring Five of something, but what? You are declaring five pointer-to-pointer-to-int. Can you do that? Sure.

So what do you do with a pointer-to-pointer-to-something? The pointer-to-poitner forms the backbone of dynamically allocated and reallocated collection of types. They are commonly termed "dynamically allocated arrays", but that is somewhat a misnomer, because there is no guarantee that all values will be sequential in memory. You will declare a given number of pointers to each int** in the array. You do not have to allocate an equal number of pointers.

(note: there is no guarantee that the memory pointed to by the pointers will even be sequential, though the pointers themselves will be -- make sure you understand this distinction and what an "Array" guarantees and what pointers don't)

int** arr[5] declares five int**. You are then free to assign any address to you like to each of the five pointers, as long as the type is int**. For example, you will allocate for your pointers with something similar to:

  arr[i] = calloc (ROW, sizeof *arr[i]);  /* allocates ROW number of pointers */

Then you are free to allocate any number of int and assign that address to each pointer, e.g.

  arr[i][j] = calloc (COL, sizeof *arr[i][j]); /* allocates COL ints */

You can then loop over the integers assigning values:

  arr[i][j][k] = v++;

A short example using your int** arr[5] type allocation could be similar to:

#include <stdio.h>
#include <stdlib.h>

#define ROW 3
#define COL ROW
#define MAX 5

int main (void) {

    int **arr[MAX] = { NULL },  /* 5 pointer-to-pointer-to-int */
        i, j, k, v = 0;

    for (i = 0; i < MAX; i++) { /* allocate ROW pointers to each */
        if ((arr[i] = calloc (ROW, sizeof *arr[i])) == NULL) {
            perror ("calloc - pointers");
            return 1;
        }
        for (j = 0; j < ROW; j++) { /* allocate COL ints each pointer */
            if ((arr[i][j] = calloc (COL, sizeof *arr[i][j])) == NULL) {
                perror ("calloc - integers");
                return 1;
            }
            for (k = 0; k < COL; k++)   /* assign values to ints */
                arr[i][j][k] = v++;
        }
    }

    for (i = 0; i < MAX; i++) { /* output each pointer-to-pointer to int */
        printf ("pointer-to-pointer-to-int: %d\n\n", i);
        for (j = 0; j < ROW; j++) {     /* for each allocated pointer */
            for (k = 0; k < COL; k++)   /* output COL ints */
                printf ("  %4d", arr[i][j][k]);
            free (arr[i][j]);   /* free the ints */
            putchar ('\n');
        }
        free (arr[i]);      /* free the pointer */
        putchar ('\n');
    }

    return 0;
}

You have allocated for five simulated 2D arrays assigning the pointer to each to your array of int **arr[5], the output would be:

Example Use/Output

$ ./bin/array_ptr2ptr2int
pointer-to-pointer-to-int: 0

     0     1     2
     3     4     5
     6     7     8

pointer-to-pointer-to-int: 1

     9    10    11
    12    13    14
    15    16    17

pointer-to-pointer-to-int: 2

    18    19    20
    21    22    23
    24    25    26

pointer-to-pointer-to-int: 3

    27    28    29
    30    31    32
    33    34    35

pointer-to-pointer-to-int: 4

    36    37    38
    39    40    41
    42    43    44

Hopefully this has helped with the distinction between an array of pointers, and an array of pointers-to-pointer and shown how to declare and use each. If you have any further questions, don't hesitate to ask.

2 of 3
3

An array of pointers to ints;

int x = 1;
int y = 42;
int z = 12;

int * array[3];

array[0] = &x;
array[1] = &y;
array[2] = &z;

alternate syntax

int * array[] = {&x,&y,&z};

keeping it simple. Work upwards from there

Discussions

array of pointers to different types C
EEVblog Captcha · We have seen a lot of robot like traffic coming from your IP range, please confirm you're not a robot · This security check has been powered by · CrowdSec More on eevblog.com
🌐 eevblog.com
December 5, 2023
Confused about pointer pointers and array pointers
dont combine multi dimension arrays and pointers, ull get lost very quick as for ur actual question, someone smarter than me might answer More on reddit.com
🌐 r/C_Programming
11
2
October 20, 2023
What are Array of Pointers?
If you have something like const char *argv[] = {"./a.out", "hello", NULL}; You get this in memory: argv ┌───────┐ ┌─────────┐ │ ptr ├───►│ ./a.out │ ├───────┤ └─────────┘ │ ptr ├─┐ ├───────┤ │ ┌─────────┐ │ NULL │ └─►│ hello │ └───────┘ └─────────┘ You can see that the "./a.out" and "hello" are stored in other places in memory, not inside the array. That’s what a pointer is—a value that can point to another location in memory. Or it can be NULL, which does not point to anything. More on reddit.com
🌐 r/C_Programming
32
37
December 17, 2024
Are C arrays pointers ?
Is it because arrays are not pointers and increment operator is not defined for arrays ? That is correct. Technically speaking, even in myArray++ the array is converted to a pointer. However, that pointer does not have a location in memory — it is not an "lvalue". The increment operator can only be used on mutable lvalues. It's pretty much the same reason 42++ makes no sense. 42 doesn't have a location in memory either. More on reddit.com
🌐 r/C_Programming
30
43
June 5, 2024
🌐
Reddit
reddit.com › r/c_programming › what are array of pointers?
r/C_Programming on Reddit: What are Array of Pointers?
December 17, 2024 -

So i am learning command lines arguments and just came cross char *argv[]. What does this actually do, I understand that this makes every element in the array a pointer to char, but i can't get around as to how all of this is happening. How does it treat every other element as another string? How come because essentialy as of my understanding rn, a simple char would treat as a single contiguous block of memory, how come turning this pointer to another pointer of char point to individual elements of string?

🌐
Cornell Computer Science
cs.cornell.edu › courses › cs3410 › 2024fa › notes › pointer.html
Arrays & Pointers - CS 3410
You can think of the array having a base address \(b\). Then, the address of an element at index \(i\) has this address: ... In fact, C lets you treat an array itself as if it were a pointer to the first element: i.e., the base address \(b\).
🌐
W3Schools
w3schools.com › c › c_pointers_arrays.php
C Pointers and Arrays
Use C pointers to access and step through the elements of an array.
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_array_of_pointers.htm
Array of Pointers in C
C - Pointers vs. Multi-dimensional Arrays ... Just like an integer array holds a collection of integer variables, an array of pointers would hold variables of pointer type.
Find elsewhere
🌐
Medium
safalgautam.medium.com › c-pointers-and-arrays-complete-foundation-guide-b287778f19eb
C Pointers and Arrays — Complete Foundation Guide | by SAFAL GAUTAM | Medium
April 26, 2026 - The key rule: arrays decay into pointers when passed to functions. ... What actually gets passed? Not all 5 elements. Not a copy. Just one address — the address of a[0]. That's it.
🌐
Sdds
intro2c.sdds.ca › pointers, arrays and structs
Pointers, Arrays and Structs | Introduction to C
Learning pointer arithmetic clarifies this equivalence between pointers an arrays. We can obtain the address of an array element by multiplying the element's index by the number of bytes that each element occupies and add that product to the array's starting address.
🌐
Medium
medium.com › @Dev_Frank › pointer-arrays-08100ef37ede
POINTER & ARRAYS. Understanding C Pointers and Arrays | by Dev Frank | Medium
February 17, 2024 - Notice that the last digits in each element’s memory address differ, incrementing by 4, reflecting the typical size of an integer (4 bytes). In C, the array’s name is essentially a pointer to its first element.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › pointer-array-array-pointer
Pointer to an Array | Array Pointer - GeeksforGeeks
Here ptr is pointer that points to an array of 10 integers. Since subscript have higher precedence than indirection, it is necessary to enclose the indirection operator and pointer name inside parentheses. The following examples demonstrate the use pf pointer to an array in C and also highlights ...
Published: April 30, 2025
🌐
DataFlair
data-flair.training › blogs › pointers-to-an-array-in-c
Pointers to an Array in C - DataFlair
March 9, 2024 - By assigning arr to ptr, we enable subscripting to access elements of the 2-D array efficiently. Our adventure via pointers to arrays in C programming has traversed the foundational aspects, delved into the nuances of pointer mathematics, illuminated the sizes of tips, and unveiled the mysteries of multidimensional arrays.
🌐
EEVblog
eevblog.com › forum › programming › array-of-pointers-to-different-types-c
array of pointers to different types C
December 5, 2023 - EEVblog Captcha · We have seen a lot of robot like traffic coming from your IP range, please confirm you're not a robot · This security check has been powered by · CrowdSec
🌐
Microchip Developer Help
developerhelp.microchip.com › xwiki › bin › view › software-tools › compilers › c-programming › data-pointers › arrays-of-pointers
C Programming Arrays Of Pointers - Developer Help
August 26, 2025 - Are you sure you want to leave ... the changes auto-saved by the realtime editing session. ... An array of pointers is an ordinary array variable whose elements happen to be all pointers....
🌐
YouTube
youtube.com › watch
#24 C Pointers and Arrays | C Programming For Beginners - YouTube
#24 C Pointers and Arrays | C Programming For BeginnersIn the last video, we learned about Pointers in C. We learned about working with memory addresses. Now...
Published: April 6, 2022
🌐
DEV Community
dev.to › missmati › pointers-arrays-strings-in-c-52h3
Pointers , Arrays & Strings in C - DEV Community
October 11, 2022 - An array of pointers stores the addresses of all the elements of the array and an array of string pointers stores the addresses of the strings present in the array. The array contains the base address of every String element in the array.
🌐
GNU
gnu.org › software › c-intro-and-ref › manual › html_node › Pointers-and-Arrays.html
Pointers and Arrays (GNU C Language Manual)
Since square brackets are defined in terms of such an addition, array[3] first converts array to a pointer.
🌐
Unstop
unstop.com › home › blog › array of pointers in c explained with detailed code examples
Array Of Pointers In C Explained With Detailed Code Examples
February 29, 2024 - An array of pointers in C is a data structure containing pointers to variables of the same data types that are stored in continuous memory locations.
🌐
Dyclassroom
dyclassroom.com › c › c-array-of-pointers
C - Array of Pointers - C Programming - dyclassroom | Have fun learning :-)
Since we have four integer pointers so, we can either create four separate integer pointer variables like ptr1, ptr2, ptr3 and ptr4. Or, we can create one single integer array of pointers ptr variable that will point at the four variables.
🌐
TutorialRide
tutorialride.com › c-programming › array-of-pointers-in-c-programming.htm
Array of Pointers in C Programming
August 2, 2016 - Syntax: data-type *array-name[expression]; Where, expression - is the number of elements to be taken in the array. The square bracket over here will take the precedence over the '*' operator.
🌐
Go
go.dev › doc › effective_go
Effective Go - The Go Programming Language
The size of an array is part of its type. The types [10]int and [20]int are distinct. The value property can be useful but also expensive; if you want C-like behavior and efficiency, you can pass a pointer to the array.