Hello everyone my name is Atharva and we are continuing this C programming course… (Pause 6 sec)
In the last video, we have discussed pointer arithmetic, and we have seen how our increment operators, decrement operators, or if we want to add or subtract any constant on our pointer.
After operating it, at the end, the value that comes, how does it come? All these things we had discussed in the last video.
Now continuing this flow, we will be discussing one more concept, which is called an array of pointers.
Now we have made the array of integers, we have also made an array of the float, we can also make char (pronunciation: kair) arrays which we call as strings.
We will see that further, but if we say that, we have to make an array of pointers, which means how to make? We have to consider pointers as an element, and the pointers chain is made, and we call it an array.
That we have to make, so how can we make that? This is what we will be seeing in this video.
So, without any delay we will start, and first of all we will see, if we are talking about an array of pointers, what exactly is array of pointers.
So, what is an array of pointers? So, we will start with the definition, because if we talk about the definition of the entire concept, our definition converts it into one or two lines and easily tells us.
So, we will first of all start with our definition.
And what does our definition say? It says that an array, where the elements would be pointers, that will store addresses of some other variables.
So, what have we seen here? Like we were making the arrays, in fact in the last video, when we made one array, that was integer type.
Which means whatever value was stored in it, it was integers but if we want to make such a scenario, where, the elements of an array, inside that pointer’s value get stored.
So how will we make that, this is what we are going to see in this video.
So, an array of pointers means, an array in which whatever elements are there, all those are also pointers.
So, this array of pointers concept, this is what we will be discussing in this video.
So, first of all, we will see how different the syntax will be, as we know how to make an array.
But if you want to make an array of the pointers, what is the difference in that, so there is only a difference of an asterisk mark.
So, here in the syntax, you can see that the way we were making the array, which means first the data type then the array’s name and then in the bracket size of the array.
In the same way we are going to make an array of pointers here.
But the only difference would be, before the name of the array there would be one Asterix symbol, with which we get to know that this is not a normal array, this is the array of pointers.
So, whatever value is stored in it, that would be the pointer’s value.
So, this was about our definition and the syntax.
Now we will see how this array of pointers helps us.
Why do we have to make an array of pointers, when our work is happening? By making a normal pointer, we were able to point any variable easily and be able to store its address.
So, what is the need that, we have to make the array also of a pointer.
So, with the help of an array of pointers, we can use it, to point to each element of another array, so here it is a little deep.
In the last video, we had made one array, but to point its element, we had made two different pointers.
So, we had made one P pointer and one Q pointer but our array’s size was five, and we had made two pointers.
So, if we have to point to each element, it is not that compatible.
Which means two pointers could not point five elements at one time.
So, this is one small example.
If I say that, my array is of 100 elements and I want to point at every element, with the help of a pointer.
Is that going to be possible? Will I be able to make 100 pointers at one time, I won't be able to make? To counter this concept, we used an array of pointers.
What I did was, of whichever size a normal array was, it was which we had to point at.
We made an array of pointers of the same size.
In that, whichever element was there, which means whichever pointers were there.
Each pointer is pointing at another pointer’s element.
So, in this way how many arrays we have to make, which we had to point, in this way how many ever array we had to make, we could make that size of array of pointers and we could point all the elements.
So, this is a small concept of an array of pointers, as what was needed to make a pointer's array.
So, if we have a really long array, even if that array is of 100 elements, then I want to store the address of each element with me.
So, if I want to use it in any of the scenarios, how can I do that? I will make one array of pointers of the same exact size.
So, what will happen with the same size, I will get those many pointers and each pointer will be pointing at the front array’s each element.
So, here if we suppose, on an array of a pointer's 0th index position, the pointer that is there, it
will point at any value which is on the 0th index position and correspondingly, the first
index position pointer would be pointing at our second array’s first index
In this way, the pointing will go on.
In this way we could point to a completely filled array easily, with the help of an array of pointers.
So, this was the concept of array of pointers, if we go ahead, there is one more small concept ahead which is called pointer to pointers.
So, we had seen that, we had to only point at one array.
So, we have made the same type of array of pointers, and that pointer was able to point to that array, but if I talk, I have one pointer, which I have to point with some other pointer.
So, here the thing becomes a little complex to hear, so first of all we will see the definition, because of it the things will get a little clearer.
A concept where a pointer stores the address of another pointer in it, which means that there is one pointer made from early on, which is pointing some other variable, but if this pointer also, if I want to point with some third pointer, at that time, the concept’s name is pointer to pointers.
And these are such kinds of pointers, which are not pointing at other variables, but are pointing at other pointers, the pointer’s address location, they are pointing at that.
So, this is the concept of pointer to pointers.
And if we talk about its syntax, how its syntax will be different from a normal pointer, so here we can see that, its syntax is similar to a normal pointer.
The only thing is that, there is one more asterisk that has been added in it.
So, which means whenever you are defining, that I have to make a pointer of integer data type, what I will do is, I will put two asterisk marks in front of it, and then I will write the pointer’s name in this way basically I will define pointer to pointer.
If we were defining a simple pointer, in a simple pointer there would come only one asterisk sign.
Here rather than pointing at another variable, if we are pointing at another pointer.
That’s why we are using 2 Asterix symbols while defining our pointer.
So, in this video, we have discussed two small concepts, an array of pointers.
Where can we use the array of pointers, we have even seen that.
Along with that, we have also seen pointer to pointers, how on one pointer another pointer can point.
And this chain, will keep getting longer.
So, all the things we have seen in this video, you can explore more about these and you can practise these so that you can use them in your implementation, and your programmes and make them effective.
If you have any queries or comments, click the discussion button below the video and post there. This way, you will be able to connect to fellow learners and discuss the course. Also, Our Team will try to solve your queries.
Very happy 😄😁
Very happy and greatful, thank you , great course.
Super for poor students to learn software course languages TQ