declare

array of pointers in c programming



Sharing buttons:

ha students let us continue with the

point is topic in the previous video I

explained about the arrays and pointers

now let us see what is arrays of

pointers so as a group of arrays will be

there so those represent it pointers

arrays of pointers so it's nothing but

it is a collection of addresses so

arrays of pointers means it is a

collection of addresses or collection of

pointers so pointer itself is you call

it as an entrance

so arrays of pointers means collection

of addresses so let how we declare there

is of pointer declaration first data

type pointer pointer name and the size

of an array so here in previous pointers

and arrays what we had taken first we

declare the array after that the base

address is assigning to the pointer so

that is the arrays and pointers then

arrays of pointers means a collection of

addresses how we store the collection of

addresses so a pointer a pointer name

and the size it indicates a collection

of addresses so let us see how we

declare it in the example int is the

data type pointer P of 5 pointer P of 5

so this represents it represents an

array so this is an array of pointers

array of pointers that can hold 5

integer element addresses so here it's

towards the 5 integer elements addresses

so arrays of pointers collection of

addresses so 5 integer

addresses will be stored in P off

pointer P of 1 P of 0 P of 1 P of 2 P of

3 P of 4 which holds the five integer

element addresses now let us see the

initialization so here we have seen the

declaration now we'll see the

initialization so the same for that

whatever we have seen the address is

used if ur ampersand symbol is used

differ initially ization so the same

example int a of 3 so it's a general 10

20 30

int pointer P of 3 comma I so to access

this we need fur I is equal to 0 I less

than 3 I plus plus P of I is equal to

address of a of 5 so that will be

assigned to the pointer so this is a

initialization initialization of a array

of pointers so first you have to declare

the array of pointers so here the three

elements that holds address of the

elements pointer P of 3 so when this

each each pointer can be accessed by

using this this is the initialization P

of I is equal to address of a of I now

let us see the program of this array of

pointers so here this is the declaration

and initialization now let us see the

accessing also then we will see the

program

so here the accessing

how we can access the array of pointers

accessing so for accessing the array of

pointers we need the indirect

indirection operator indirection

operator that is pointer is used if ur

accessing okay so let's see the example

how to access the array of pointers you

have to use a for loop so it to access

the array you need furlough so array of

pointers means for I is equal to 0 I

less than 3 I plus plus you have to use

a printf for accessing the elements that

is pointer P of I so this is accessing

go in now let us see the program for

this program for array of pointers hash

include stdio.h okay now writing the

main program first I am declaring the

array of three elements that is

initializing 10 20 30 so this is a

single dimensional array so after that I

want to declare the array of pointers

point pointer of 3 and I for for loop

for I is equal to 0 I less than 3 I plus

plus you have to printer you have to

assign the each address of an array of

element to the pointer variable so after

that we have to print that pointer

variable you have to if you want to get

the value of that this is a it P of I

now holds the address so if you

represent pointer P or fine-pointed P of

I means it prints whatever the value

that is present in that address location

so P of I is equal to address of a of I

now printf

elements of the array or so for printing

each value by using the pointers means

you need to write the for loop printf %

LD I'm using the tab space for each

element pointer P of I so pointer P of I

means it holds the it prints the values

and this princely it holds the address P

off eyeholes address pointer P of I

holds the value of that in that address

close the main then what will be the

output here the output is first elements

of array or so here I already declare

initialized average so this is a

compile-time initialization so directly

prints elements of array or 10-20-30

so with tab space so this is about the

array of pointers thank you