Allocated Array

With an allocated array it's straightforward enough to follow.

Declare your array of pointers. Each element in this array points to a struct Test:

struct Test *array[50];

Then allocate and assign the pointers to the structures however you want. Using a loop would be simple:

array[n] = malloc(sizeof(struct Test));

Then declare a pointer to this array:

                               // an explicit pointer to an array 
struct Test *(*p)[] = &array;  // of pointers to structs

This allows you to use (*p)[n]->data; to reference the nth member.

Don't worry if this stuff is confusing. It's probably the most difficult aspect of C.


Dynamic Linear Array

If you just want to allocate a block of structs (effectively an array of structs, not pointers to structs), and have a pointer to the block, you can do it more easily:

struct Test *p = malloc(100 * sizeof(struct Test));  // allocates 100 linear
                                                     // structs

You can then point to this pointer:

struct Test **pp = &p

You don't have an array of pointers to structs any more, but it simplifies the whole thing considerably.


Dynamic Array of Dynamically Allocated Structs

The most flexible, but not often needed. It's very similar to the first example, but requires an extra allocation. I've written a complete program to demonstrate this that should compile fine.

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

struct Test {
    int data;
};

int main(int argc, char **argv)
{
    srand(time(NULL));

    // allocate 100 pointers, effectively an array
    struct Test **t_array = malloc(100 * sizeof(struct Test *));

    // allocate 100 structs and have the array point to them
    for (int i = 0; i < 100; i++) {
        t_array[i] = malloc(sizeof(struct Test));
    }

    // lets fill each Test.data with a random number!
    for (int i = 0; i < 100; i++) {
        t_array[i]->data = rand() % 100;
    }

    // now define a pointer to the array
    struct Test ***p = &t_array;
    printf("p points to an array of pointers.\n"
       "The third element of the array points to a structure,\n"
       "and the data member of that structure is: %d\n", (*p)[2]->data);

    return 0;
}

Output:

> p points to an array of pointers.
> The third element of the array points to a structure,
> and the data member of that structure is: 49

Or the whole set:

for (int i = 0; i < 100; i++) {
    if (i % 10 == 0)
        printf("\n");
    printf("%3d ", (*p)[i]->data);
}

 35  66  40  24  32  27  39  64  65  26 
 32  30  72  84  85  95  14  25  11  40 
 30  16  47  21  80  57  25  34  47  19 
 56  82  38  96   6  22  76  97  87  93 
 75  19  24  47  55   9  43  69  86   6 
 61  17  23   8  38  55  65  16  90  12 
 87  46  46  25  42   4  48  70  53  35 
 64  29   6  40  76  13   1  71  82  88 
 78  44  57  53   4  47   8  70  63  98 
 34  51  44  33  28  39  37  76   9  91 

Dynamic Pointer Array of Single-Dynamic Allocated Structs

This last example is rather specific. It is a dynamic array of pointers as we've seen in previous examples, but unlike those, the elements are all allocated in a single allocation. This has its uses, most notable for sorting data in different configurations while leaving the original allocation undisturbed.

We start by allocating a single block of elements as we do in the most basic single-block allocation:

struct Test *arr = malloc(N*sizeof(*arr));

Now we allocate a separate block of pointers:

struct Test **ptrs = malloc(N*sizeof(*ptrs));

We then populate each slot in our pointer list with the address of one of our original array. Since pointer arithmetic allows us to move from element to element address, this is straight-forward:

for (int i=0;i<N;++i)
    ptrs[i] = arr+i;

At this point the following both refer to the same element field

arr[1].data = 1;
ptrs[1]->data = 1;

And after review the above, I hope it is clear why.

When we're done with the pointer array and the original block array they are freed as:

free(ptrs);
free(arr);

Note: we do NOT free each item in the ptrs[] array individually. That is not how they were allocated. They were allocated as a single block (pointed to by arr), and that is how they should be freed.

So why would someone want to do this? Several reasons.

First, it radically reduces the number of memory allocation calls. Rather then N+1 (one for the pointer array, N for individual structures) you now have only two: one for the array block, and one for the pointer array. Memory allocations are one of the most expensive operations a program can request, and where possible, it is desirable to minimize them (note: file IO is another, fyi).

Another reason: Multiple representations of the same base array of data. Suppose you wanted to sort the data both ascending and descending, and have both sorted representations available at the same time. You could duplicate the data array, but that would require a lot of copying and eat significant memory usage. Instead, just allocate an extra pointer array and fill it with addresses from the base array, then sort that pointer array. This has especially significant benefits when the data being sorted is large (perhaps kilobytes, or even larger, per item) The original items remain in their original locations in the base array, but now you have a very efficient mechanism in which you can sort them without having to actually move them. You sort the array of pointers to items; the items don't get moved at all.

I realize this is an awful lot to take in, but pointer usage is critical to understanding the many powerful things you can do with the C language, so hit the books and keep refreshing your memory. It will come back.

Answer from teppic on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › c language › how-to-declare-and-initialize-an-array-of-pointers-to-a-structure-in-c
How to Declare and Initialize an Array of Pointers to a Structure in C? - GeeksforGeeks
July 23, 2025 - Now, it is made a triple pointer because we are accessing those arrays, whose each element has a pointer to another array (subarray). And each element of those sub-arrays, have a pointer to the structure. Each index of st_arr[i] contains sub-arrays.
Top answer
1 of 4
112

Allocated Array

With an allocated array it's straightforward enough to follow.

Declare your array of pointers. Each element in this array points to a struct Test:

struct Test *array[50];

Then allocate and assign the pointers to the structures however you want. Using a loop would be simple:

array[n] = malloc(sizeof(struct Test));

Then declare a pointer to this array:

                               // an explicit pointer to an array 
struct Test *(*p)[] = &array;  // of pointers to structs

This allows you to use (*p)[n]->data; to reference the nth member.

Don't worry if this stuff is confusing. It's probably the most difficult aspect of C.


Dynamic Linear Array

If you just want to allocate a block of structs (effectively an array of structs, not pointers to structs), and have a pointer to the block, you can do it more easily:

struct Test *p = malloc(100 * sizeof(struct Test));  // allocates 100 linear
                                                     // structs

You can then point to this pointer:

struct Test **pp = &p

You don't have an array of pointers to structs any more, but it simplifies the whole thing considerably.


Dynamic Array of Dynamically Allocated Structs

The most flexible, but not often needed. It's very similar to the first example, but requires an extra allocation. I've written a complete program to demonstrate this that should compile fine.

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

struct Test {
    int data;
};

int main(int argc, char **argv)
{
    srand(time(NULL));

    // allocate 100 pointers, effectively an array
    struct Test **t_array = malloc(100 * sizeof(struct Test *));

    // allocate 100 structs and have the array point to them
    for (int i = 0; i < 100; i++) {
        t_array[i] = malloc(sizeof(struct Test));
    }

    // lets fill each Test.data with a random number!
    for (int i = 0; i < 100; i++) {
        t_array[i]->data = rand() % 100;
    }

    // now define a pointer to the array
    struct Test ***p = &t_array;
    printf("p points to an array of pointers.\n"
       "The third element of the array points to a structure,\n"
       "and the data member of that structure is: %d\n", (*p)[2]->data);

    return 0;
}

Output:

> p points to an array of pointers.
> The third element of the array points to a structure,
> and the data member of that structure is: 49

Or the whole set:

for (int i = 0; i < 100; i++) {
    if (i % 10 == 0)
        printf("\n");
    printf("%3d ", (*p)[i]->data);
}

 35  66  40  24  32  27  39  64  65  26 
 32  30  72  84  85  95  14  25  11  40 
 30  16  47  21  80  57  25  34  47  19 
 56  82  38  96   6  22  76  97  87  93 
 75  19  24  47  55   9  43  69  86   6 
 61  17  23   8  38  55  65  16  90  12 
 87  46  46  25  42   4  48  70  53  35 
 64  29   6  40  76  13   1  71  82  88 
 78  44  57  53   4  47   8  70  63  98 
 34  51  44  33  28  39  37  76   9  91 

Dynamic Pointer Array of Single-Dynamic Allocated Structs

This last example is rather specific. It is a dynamic array of pointers as we've seen in previous examples, but unlike those, the elements are all allocated in a single allocation. This has its uses, most notable for sorting data in different configurations while leaving the original allocation undisturbed.

We start by allocating a single block of elements as we do in the most basic single-block allocation:

struct Test *arr = malloc(N*sizeof(*arr));

Now we allocate a separate block of pointers:

struct Test **ptrs = malloc(N*sizeof(*ptrs));

We then populate each slot in our pointer list with the address of one of our original array. Since pointer arithmetic allows us to move from element to element address, this is straight-forward:

for (int i=0;i<N;++i)
    ptrs[i] = arr+i;

At this point the following both refer to the same element field

arr[1].data = 1;
ptrs[1]->data = 1;

And after review the above, I hope it is clear why.

When we're done with the pointer array and the original block array they are freed as:

free(ptrs);
free(arr);

Note: we do NOT free each item in the ptrs[] array individually. That is not how they were allocated. They were allocated as a single block (pointed to by arr), and that is how they should be freed.

So why would someone want to do this? Several reasons.

First, it radically reduces the number of memory allocation calls. Rather then N+1 (one for the pointer array, N for individual structures) you now have only two: one for the array block, and one for the pointer array. Memory allocations are one of the most expensive operations a program can request, and where possible, it is desirable to minimize them (note: file IO is another, fyi).

Another reason: Multiple representations of the same base array of data. Suppose you wanted to sort the data both ascending and descending, and have both sorted representations available at the same time. You could duplicate the data array, but that would require a lot of copying and eat significant memory usage. Instead, just allocate an extra pointer array and fill it with addresses from the base array, then sort that pointer array. This has especially significant benefits when the data being sorted is large (perhaps kilobytes, or even larger, per item) The original items remain in their original locations in the base array, but now you have a very efficient mechanism in which you can sort them without having to actually move them. You sort the array of pointers to items; the items don't get moved at all.

I realize this is an awful lot to take in, but pointer usage is critical to understanding the many powerful things you can do with the C language, so hit the books and keep refreshing your memory. It will come back.

2 of 4
5

It may be better to declare an actual array, as others have suggested, but your question seems to be more about memory management so I'll discuss that.

struct Test **array1;

This is a pointer to the address of a struct Test. (Not a pointer to the struct itself; it's a pointer to a memory location that holds the address of the struct.) The declaration allocates memory for the pointer, but not for the items it points to. Since an array can be accessed via pointers, you can work with *array1 as a pointer to an array whose elements are of type struct Test. But there is not yet an actual array for it to point to.

array1 = malloc(MAX * sizeof(struct Test *));

This allocates memory to hold MAX pointers to items of type struct Test. Again, it does not allocate memory for the structs themselves; only for a list of pointers. But now you can treat array as a pointer to an allocated array of pointers.

In order to use array1, you need to create the actual structs. You can do this by simply declaring each struct with

struct Test testStruct0;  // Declare a struct.
struct Test testStruct1;
array1[0] = &testStruct0;  // Point to the struct.
array1[1] = &testStruct1;

You can also allocate the structs on the heap:

for (int i=0; i<MAX; ++i) {
  array1[i] = malloc(sizeof(struct Test));
}

Once you've allocated memory, you can create a new variable that points to the same list of structs:

struct Test **array2 = array1;

You don't need to allocate any additional memory, because array2 points to the same memory you've allocated to array1.


Sometimes you want to have a pointer to a list of pointers, but unless you're doing something fancy, you may be able to use

struct Test *array1 = malloc(MAX * sizeof(struct Test));  // Pointer to MAX structs

This declares the pointer array1, allocated enough memory for MAX structures, and points array1 to that memory. Now you can access the structs like this:

struct Test testStruct0 = array1[0];     // Copies the 0th struct.
struct Test testStruct0a= *array1;       // Copies the 0th struct, as above.
struct Test *ptrStruct0 = array1;        // Points to the 0th struct.

struct Test testStruct1 = array1[1];     // Copies the 1st struct.
struct Test testStruct1a= *(array1 + 1); // Copies the 1st struct, as above.
struct Test *ptrStruct1 = array1 + 1;    // Points to the 1st struct.
struct Test *ptrStruct1 = &array1[1];    // Points to the 1st struct, as above.

So what's the difference? A few things. Clearly, the first method requires you to allocate memory for the pointers, and then allocate additional space for the structs themselves; the second lets you get away with one malloc() call. What does the extra work buy you?

Since the first method gives you an actual array of pointers to Test structs, each pointer can point to any Test struct, anywhere in memory; they needn't be contiguous. Moreover, you can allocate and free the memory for each actual Test struct as necessary, and you can reassign the pointers. So, for example, you can swap two structures by simply exchanging their pointers:

struct Test *tmp = array1[2];  // Save the pointer to one struct.
array1[2] = array1[5];         // Aim the pointer at a different struct.
array1[5] = tmp;               // Aim the other pointer at the original struct.

On the other hand, the second method allocates a single contiguous block of memory for all of the Test structs and partitions it into MAX items. And each element in the array resides at a fixed position; the only way to swap two structures is to copy them.

Pointers are one of the most useful constructs in C, but they can also be among the most difficult to understand. If you plan to continue using C, it'll probably be a worthwhile investment to spend some time playing with pointers, arrays, and a debugger until you're comfortable with them.

Good luck!

Discussions

c pointer to array of structs - Stack Overflow
I know this question has been asked a lot, but I'm still unclear how to access the structs. I want to make a global pointer to an array of structs: typdef struct test { int obj1; int obj2... More on stackoverflow.com
🌐 stackoverflow.com
Pointer to an array of structure in C - Stack Overflow
Your two choices are to use a pointer ... or pointer to array &sTestStructure which has type tTest (*)[20]. The first choice is far more common in C. ... Yes, my comment is totally wrong. ... Remember that unless it is the operand of the sizeof or unary & operators, or is a string literal used to initialize a character array in a ... More on stackoverflow.com
🌐 stackoverflow.com
c - array of structure pointers - Stack Overflow
You will want to review: Is it a good idea to typedef pointers?. David C. Rankin – David C. Rankin · 2018-11-21 23:00:14 +00:00 Commented Nov 21, 2018 at 23:00 · What is countries_array = (pCountry); supposed to mean? Was that intended to be a type cast of the result of the next line? More on stackoverflow.com
🌐 stackoverflow.com
c - Pointer to array of structures - explanation - Stack Overflow
Is it true, that structure Array contains array of structures Object? If so, how? I don't see any square brackets here. Can someone explain what is happening inside? Not sure about pointers. How can I for example initialise structure Array, which will contain amount of structures Object depending ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/cprogramming › array of struct pointers
r/cprogramming on Reddit: Array of struct pointers
May 1, 2024 -

Hi, I am new to C and I want to know why I am getting Segmentation fault error if I declare array of size 10 and try to insert values for first element, but if I make array size to be 1, I am able to print the values correctly.

#include <stdio.h>

typedef struct Person {
  char *name;
  int age;
} person_t;

int main(void) {
  person_t *arr[10];

  arr[0]->name = "John Doe";
  arr[0]->age = 22;

  printf("Name: %s\n", arr[0]->name);
  printf("Age: %d\n", arr[0]->age);
  return 0;
}
🌐
Quora
quora.com › How-can-I-make-an-array-of-pointers-to-structs-in-c
How to make an array of pointers to structs in c - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
HowStuffWorks
computer.howstuffworks.com › tech › computer software › programming
Pointers to Structures - The Basics of C Programming | HowStuffWorks
March 8, 2023 - Sometimes a great deal of space can be saved, or certain memory-intensive problems can be solved, by declaring an array of pointers. In the example code below, an array of 10 pointers to structures is declared, instead of declaring an array of structures. If an array of the structures had been created instead, 243 * 10 = 2,430 bytes would have been required for the array.
Top answer
1 of 4
29

The syntax you are looking for is somewhat cumbersome, but it looks like this:

// Declare test_array_ptr as pointer to array of test_t
test_t (*test_array_ptr)[];

You can then use it like so:

test_array_ptr = &array_t1;
(*test_array_ptr)[0] = new_struct;

To make the syntax easier to understand, you can use a typedef:

// Declare test_array as typedef of "array of test_t"
typedef test_t test_array[];
...
// Declare test_array_ptr as pointer to test_array
test_array *test_array_ptr = &array_t1;
(*test_array_ptr)[0] = new_struct;

The cdecl utility is useful for deciphering complex C declarations, especially when arrays and function pointers get involved.

2 of 4
6

test_t * test_array_ptr is a pointer to test_t. It could be a pointer to single instance of test_t, but it could be a pointer to the first element of an array of instances of test_t:

test_t array1[1024];

test_t *myArray;
myArray= &array1[0];

this makes myArray point to the first element of array1 and pointer arithmetic allows you to treat this pointer as an array as well. Now you could access 2nd element of array1 like this: myArray[1], which is equal to *(myArray + 1).

But from what I understand, what you actually want to do here is to declare a pointer to pointer to test_t that will represent an array of pointers to arrays:

test_t array1[1024];
test_t array2[1024];
test_t array3[1025];

test_t **arrayPtr;
arrayPtr = malloc(3 * sizeof(test_t*));   // array of 3 pointers
arrayPtr[0] = &array1[0];
arrayPtr[1] = &array2[0];
arrayPtr[2] = &array3[0];
Find elsewhere
🌐
Linux Hint
linuxhint.com › make-array-structs-c
How to Make an Array of Structs in C – Linux Hint
To access the structure members with the help of pointers can be done as follows: ... So far, we discussed the single structure object. Both the ways of access of member elements, we have seen through pointers and the direct access with objects. We have two ways to define the structures, first is to define the structure object and another way is to define the pointer to the structure. Structure object: Struct abc obj; Structure pointer: Struct abc *ptr; Now, let us discuss the array of structure objects and array of structure pointers.
Top answer
1 of 2
1

Remember that unless it is the operand of the sizeof or unary & operators, or is a string literal used to initialize a character array in a declaration, an expression of type "N-element array of T" (T [N]) will be converted ("decay") to an expression of type "pointer to T" (T *), and the value of the expression will be the address of the first element of the array.

This naturally leads us to the following:

tTest *ptr = sTestStructure;  // note no & operator!

The expression sTestStructure is implicitly converted from type "20-element array of tTest" to "pointer to tTest", and the value of the expression is the same as &sTestStructure[0]. To access any element of sTestStructure, you could simply index into ptr as you would sTestStructure:

ptr[i].u8Mem1 = some_value;                // sTestStructure[i].u8Mem1 = some_value
printf( "%" PRIu8 "\n", ptr[j].u8Mem2 );

Remember that the subscript operation a[i] is defined as *(a + i); given the address a, offset i elements from that address and defereference the result. Thus, the [] operator implicitly dereferences ptr, which is why we use the . operator to access each struct member.

Alternately, you could also access struct members using the -> operator, and advance the pointer as necessary:

tTest *ptr = sTestStructure;
while( ptr->u8Mem1 != some_value )  // no subscript operation here
  ptr++;

The expression ptr->u8Mem1 is equivalent to (*ptr).u8Mem11, which is equivalent to ptr[0].u8Mem1.

So what happens if we decide to use &sTestStructure instead? Since sTestStructure is the operand of the unary & operator, the conversion rule above doesn't apply; instead of getting a pointer to a pointer to tTest, we get a pointer to a 20-element array of tTest, or:

tTest (*arrPtr)[20] = &sTestStructure;

This presents a bit more of a challenge, since we have to dereference arrPtr before we can index into it:

(*arrPtr)[i].u8Mem1 = some_value;
printf( "%" PRIu8 "\n", (*arrPtr)[j].u8Mem2 );

Since a[i] is defined as *(a + i), the expression *arrPtr can also be written as arrPtr[0] (*arrPtr == *(arrPtr + 0) == arrPtr[0]). So those lines could also be written as

arrPtr[0][i].u8Mem1 = some_value;
printf( "%" PRIu8 "\n", arrPtr[0][j].u8Mem2 );

As should be evident from those last couple of lines, you normally don't see this form of an array pointer unless you're dealing with multi-dimensional arrays. Remember our conversion rule, where an expression of type T [N] is converted to an expression of type T *? Well, replace T with an array type like Q[M], and we get the conversion from "N-element array of M-element array of Q" (Q [N][M]) to "pointer to M-element array of Q" (Q (*)[M]):

tTest sTestStructure[10][20];
tTest (*arrPtr)[20] = sTestStructure;


  1. Postfix . has higher precedence than unary *, so *ptr.u8Mem1 would be parsed as *(ptr.u8Mem1), which is not what you want here.

2 of 2
0

They already told you how to define the pointer, now if you want to access a property would be *pointer->property.....

🌐
Programiz
programiz.com › c-programming › c-structures-pointers
C structs and Pointers (With Examples)
Here's how you can create pointers to structs. struct name { member1; member2; . . }; int main() { struct name *ptr, Harry; } Here, ptr is a pointer to struct. To access members of a structure using pointers, we use the -> operator.
🌐
Sdds
intro2c.sdds.ca › pointers, arrays and structs
Pointers, Arrays and Structs | Introduction to C
The name of an array holds the address of the start of the array; that is, the name of the array is a pointer. Since arrays by definition store element data contiguously in memory, we can access any array element using pointer syntax. This chapter examines this relationship between pointers, ...
🌐
Quora
quora.com › Can-someone-give-an-example-of-an-array-of-struct-pointers-in-C
Can someone give an example of an array of struct pointers in C? - Quora
Answer (1 of 6): The First advantage of storing struct pointers instead of structs themselves in only that the array can be made before the structs are and contain null pointers. It is like you have to buy a box of envelopes with nothing in them before writing and sending a bunch of letters. Exc...
Top answer
1 of 2
1

"Is it true, that structure Array contains array of structures Object?" No it isn't. Structure Array contains a pointer, not an array. To create an arry you have to allocate memory with malloc or calloc and then assign it to this pointer.

"If I use alloc in function, how can I free it later, if I don't know, how many times I have called that function containing malloc?" There is free( void* ptr ) to clean the memory you've allocated with malloc or calloc. Have a look here for example - http://www.cplusplus.com/reference/cstdlib/free/

If you want to have an array inside you must have something like this

typedef struct {
  unsigned size;
  Object items[10];
} Array;
2 of 2
0

Array contains a pointer to Object, which can be used to point to a dynamically-allocated array, like so:

Array arr;
arr.size = 10;
arr.items = malloc( sizeof *arr.items * arr.size );

Each arr.items[i] has type Object, so you can set the id and name members like so:

arr.items[i].id = 1;
arr.items[i].name = malloc( strlen( "foo" ) + 1 );
if ( arr.items[i].name )
  strcpy( arr.items[i].name, "foo" );

When you're done, you'll need to make sure you free each arr.items[i].name before freeing arr.items:

for ( size_t i = 0; i < arr.size; i++ )
{
  free( arr.items[i].name ); // assumes memory for arr.items[i].name was
}                            // allocated with malloc, calloc, or realloc
free( arr.items );

If arr.items[i].name is set to point to a string literal or an auto array, such as

arr.items[i].name = "foo";
...
char some_array[] = "bar";
arr.items[j].name = some_array;

then you would not want to call free on those items.

🌐
Cprogramming
cboard.cprogramming.com › c-programming › 135989-array-pointers-struct.html
Array of pointers to a struct
I know linked lists already :/ Not sure how they relate to making an array hold pointers. I feel like I'm missing something basic lol. ... struct tStuff { int x; int y; char z[100]; } struct tStuff *MyStuff[500]; This declares MyStuff to be an array of pointers to tStuff structs, with enough ...
🌐
Swarthmore College
cs.swarthmore.edu › ~newhall › cs31 › resources › C-structs_pointers.php
CS31: Intro to C Structs and Pointers
ptr = NULL; *ptr = 6; // CRASH! your program crashes with a segfault (a memory fault) ptr = 20; *ptr = 6; // CRASH! segfault (20 is not a valid address) This is one reason to initialize pointer variables to NULL: you can test for NULL and not dereference in your program: ... Pointers and Functions "pass by reference" Pointers allow a way to write functions that can modify their arguments' values: the C way of implementing Pass by Reference. We have actually already seen this with array parameters: the function parameter gets the value of the base address of the array (it points to the same array as its argument) and thus the function can modify the values stored in the array buckets.
🌐
Reddit
reddit.com › r/c_programming › an array of pointers to arrays of structs
r/C_Programming on Reddit: An array of pointers to arrays of structs
July 5, 2022 -

So i have struct called Pixel

struct Pixel {

unsigned int r;

unsigned int g;

unsigned int b;

};

and letters defined as arrays of pixels

struct Pixel A [25] = {

{255,255,255},{255,255,255},{0,0,0},{255,255,255},{255,255,255},

{255,255,255},{0,0,0},{255,255,255},{0,0,0},{255,255,255},

{255,255,255},{0,0,0},{255,255,255},{0,0,0},{255,255,255},

{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},

{0,0,0},{255,255,255},{255,255,255},{255,255,255},{0,0,0}

};

now I need an array of pointers to the letters

i understand how to create pointers to array of pixels.

struct Pixel (*Ascii) [25];

but not how to create a array of those pointers

🌐
guvi.in
studytonight.com › c › pointers-to-structure-in-c.php
Pointer to Structure in C Programming
#include <stdio.h> struct Book { char name[10]; int price; } int main() { struct Book a; //Single structure variable struct Book* ptr; //Pointer of Structure type ptr = &a; struct Book b[10]; //Array of structure variables struct Book* p; //Pointer of Structure type p = &b; return 0; }