 Hello, friends. I am Sanjay Bhukta. I welcome you on Sanjay Bhukta Tech School. In this video, I'm going to explain these three points which I mentioned in front of you. So first I'm going to explain pointer, then I will be covering pointer to pointer. And lastly, I will explain you how we can use carry-off pointer. So I will be explaining all these points with the help of C-language. But before start, I want to share one information. If you go to description of this video, you will see links of various playlists related to C-language videos. So if you want to watch more programming related videos, you can follow those playlist. Now after this information, first I'm going to explain you what is pointer and how you can use it in C-language. So first I'm going to write one line statement that will explain the use of pointer. So pointer is a variable which can store address of memory location. And in programming, the memory location will be known as variable. So after declaring pointer in your C program, we will be having two type of variables. One that we are already using while implementing programming C that are normal variables which store values provided by the user. But if you want to store address of that memory location that is we are using as a variable, then we need one more variable and that variable is known as pointer. So this is a simple one line statement whenever you want to tell what is pointer. So you can use this statement. Now I'm going to take one simple example so that you can understand how you can get your pointer. So this is very common statement that you might have used in every C program that is int equals to 5. So here this a will be known as variable and this variable is storing value as 5 and let's say this is the memory location of this variable. So A is the name of this memory location. 5 is the value that is stored inside this memory location. And if we are talking about 16 bit compiler. So this A which is of indies that are variable, it will be having two bytes of memory and two bytes means we need two different addresses. So let's assume it is having two different addresses as 101 and 102. So actually it will be having two addresses and total size of this memory will be two bytes. Total size of this memory will be two bytes and we can say 16 bits. So first 8 bit will be having 101 as address. Another 8 bits will be having 102 as address. So these are addresses. This is a value and this is name of memory location. So this is what happens when we write this statement. Now if you want to access this pipe, if you want to access this pipe or you want to assign any other value into this memory. So what you will do, you will use this name that is name of this memory location and that we use with the help of this variable name. So whenever we talk about variable, we only use the name of that memory location. Now if you don't want to use name of that memory location and you want to refer that memory location with the help of address, then pointer comes into the picture. So now I'm going to declare one more statement. So this is pointer declaration. This is pointer declaration and as I said, pointer is also available. So it will be having its own memory where we can store that address. So let's say it is a block named as p and if I write this p equals to ampersand a. So here ampersand means address of. So address of a variable will be assigned into p. So here you can see this is the variable a and its address is 101. So it will be assigned into p and always remember if your memory has more than one addresses. So only beginning address will be assigned into pointer and that address can be known as base address. So if we have this variable as flow time, the flow has four bytes. So we will be having four different addresses, but pointer will be having the beginning address that is known as base address. So whenever you assign address of any variable into any pointer, so pointer will be having base or beginning address of that memory location. So this way I hope you understood how we can assign address of a variable into pointer. Now I'm going to tell you how we can access this value that is available here in this address or how we can change this value that is available on a particular address. So I'm erasing these elements. So now, so this is the important thing that is ampersand. This is another important thing. If you use this asterisk with a variable and you're using data type. So that means you are delivering a pointer. Now, if I write printf %d, %d, a, asterisk p. So you know a will print pipe because we are using this from the beginning from where you started learning programming. So you use this variable to read or print values from the user. But here we are using this asterisk p. So here the meaning of this asterisk is value at address. Here the meaning of this asterisk is value at address. So now you need to learn the difference between this asterisk or this. If you are using data type with a variable and using this asterisk, it means you are delivering a pointer. But if you are not using any data type and still you are using asterisk with a variable sign, it means you are de-referencing that pointer, which means value at address. So if I write simple p, if I write simple p, it means p is value that is 101. So it will provide me 101, but I am using asterisk also. So asterisk means value at address. So I can write this value at address, address is 101 and 101's value is 5. So at the end it will print point. So this way I hope you understood how I accessed value that is stored at this location. So I am able to access this location with the help of its name as well as with the help of this address. So while you are using pointer, it means you can access a particular location, particular memory location with its memory address. So right now you saw how I accessed 5 with the help of its address using pointer. So if pointer is having address of any variable, it means you have control on that variable with the help of that pointer. Now if I write asterisk, let's say I write a equals to 10. So it means we are assigning 10 into 8. So value of a will be 10. Now if I assign this asterisk p equals to 20. So again, you need to de-reference it so you can write it like this for understanding purpose. But actually this happens internally. So we are assigning 20 to this address and 20 will become value of this address. So you can say 101 address memory location is now having value as 20. So it means using this or this both are same. So you can access your memory location with the name of that memory location as well as with the address of that memory location. And if you are using address of that memory location, then that can happen with the help of pointer. So this was the basic that I explained about pointer. Now let's understand it with more examples. So I am going to erase all these things. So now you will relate all these examples with the explanation I explained you. So let's say we have one variable a whose value is 5. Then we have one pointer p. So you can see this memory location, this is for a and this is for p. p is having base address of our memory location a and here its value is 5. Now I can write this. So p will be having base address or beginning address of a. Now I can write this print as percenty percenty a, srp. So it will print 5. Now we are using srp. It means value at address which is available in p. So you can write it like this and value at 101 is 5. So I hope this you now understood. Now if I write this a equals to a plus srp. So it means a is having 5 plus srp. So again you can solve it like this. So srp will also provide 5. So 5 plus 5, a will be having 10 now. And if I again write this. So now you can directly say a is having 10. So it will print 10. Now again I need to solve this srp. So p is also having base address of a that is 101. So I can write srp 101. So now you need to check value at 101. So you need to check the latest value of that address. So 101 is right now having 10. So now output will be 10. So now you need to understand one more thing. So if you see this statement, I modified only a. A is what? A is name of a memory location. So this is the memory location. Its name is a. Right now its value is 10. So if a is having 10. So its address which is 101. So 101 will also be having 10 because a and 101 both are pointing to same location. Both are pointing to same location. So if I assign 10 into a, it means I am technically assigning 10 into 101 as well. Right. So one memory location is identified by two identities. One is name and another one second one is its address. So if you change that memory location with the name, then address uses modified value. If I do vice versa, if I change value through its address, then its name will be having modified. Right. So now I'm going to tell you how we can do that. So this way I can modify the value of any memory location with the help of its address. So that if we go through the sequence, so right now as this P will provide 10 because here you can see 101 value is 10. So we are having 10. A is also 10. So 10 plus 10, 20. 20 will go to as to risk P. As to risk P means value at 101. So value at 101 will become 20. So this way I modified location through its address. So if 101 address is having value as 20. So what will be the value of A? It will be 20 because both are pointing to same location. And if we, if we are modifying that location to address, so name will use the modified value. So now if I write this, so now you need to print a, we can see value of A is 20. And as to risk P. So again dereference it. So it will also print 20 because 101 is also having 20. So I hope this way you understood the use of pointer. So whenever you want to access a memory location through its address, then only you need pointer. Otherwise not. If you want to access your memory location through its name only, not through address, then you don't require any pointer because addresses are available internally, but we are not using them explicitly so pointer is not necessary. But if you want to process that memory location through the address, then pointer is necessary. So this way I hope you understood the first point that is pointer to pointer. Now I'm going to tell you how we can use pointer to pointer. So now I'm going to tell you pointer to pointer. So we understood about pointer. So pointer is available, which can store address of another variable. Now we have pointer to pointer. So pointer to pointer is also available, which can store address of pointer variable. So now we have a chain. First we need to declare a variable then pointer and then pointer to pointer. So here you can see this is a variable, which is equals to 5. This is a pointer that is p and here I'm declaring a double asterisk and double p. So this name can be anything. Right now I'm using pp pointer to pointer short form. So you can use any name here, but you need to use to asterisk. If you want to declare variable as pointer to pointer. So this pointer to pointer can store address of this pointer variable. This pointer variable can store address of this normal. This way we use. And if you want to store address of this pointer to pointer, then further you can also declare this pointer to pointer to pointer. And this can go at any depth. But we don't require these things. We only use pointer and pointer to pointer. Because if we use triple pointer and four pointers and things will become too complex. Right. So this is an option that you can use, but right now we are not using it. So I'm going to explain you how we can use these. So I hope you understood the meaning of these two operators. This is address of. And this is value at address. Right. So if I write this. So I hope you can understand. I am assigning address of p into p. So let's say this is a it's value is five. It's beginning addresses one zero one. Now this is p. It's value will be one zero one. That is address of a address of a is one zero one. So at top I'm mentioning address middle is value. And last one is me. So I'm going to explain you how to do this. And last one is me. So variable a value is five. It's addresses one zero one. Next address you can identify it will be one zero two. And I'm assuming this. These addresses in real. They can be different. So when you will be executing these programs, these examples, you will see different outputs. So don't think output will be one zero one one zero two. So these address I'm assuming they can be different in the other. Again, this is pointer. It's value is one zero one, which is address of eight. And let's say it's addresses two zero one. So again, this is address. This is actually address, but for p, this is a value. And if I declare this pointer to pointer, so this is double p, it's value will be two zero one, which is address of P. And let's say it's addresses. So again, this is address. This is value. And this is me. Right. Now if I like a single print F. Having three percent. Right. And I want to print a. And so this is value. So what will be the output? Because he's having five. Right. So it is a variable name so we can access any memory location through its name so that it can print a particular value. Now if I write a speed. So I already explained you a while explaining a pointer. If we write P. So P means one zero one. So it will provide one zero one. But if I'm writing of it with Astros time. So it's mean value at address and addresses one zero one. So value at one zero one. So value at one zero one is five. So it means P is having one zero one, which is address of this memory location. So if you have a memory address of any memory location, then without using name, you can access it. So what we are doing here. Are you. Now we have double a stress and this variable. So if I write it like this, only double P. So what is the value of double P? It is two zero one. Now if I write one stress, so it means value at address. So what is the value of this address to go to this address? It's value is one zero one. So it will provide one zero one. I'm using one more stress. So that will be applied here as this one zero one. So now again value at this address. So this address is having value is five. So what will be printed? So this way friends, you can use pointer to store address of a variable. You can use pointer to pointer to store address of a pointer. And this will be a chain. So you can use for that pointer to pointer to pointer also. If you want to store address of pointer. So this way I hope you understood how we can manage the pointer and pointer to pointer. So these are basically working on memory addresses. If you want to access any memory to its address, then only you require pointer or pointer to pointer. So I hope you understood till now. I explained this one as well. Now last is area of pointer. So I'm going to erase all these things. So area of pointer is basically a connection. At your point is basically a collection. So I hope you know, come and any collection of something. So if we declare integer added. If I declare this. So it means this variable A will hold 550 values, right? But if I declare this, so this is area of pointer. So if I remove this, so it is a pointer. If I use this, then it is area of pointer. So area of pointer can hold multiple addresses together into a single pointer. So if you want to store more than one addresses into a single pointer, then you can declare that pointer as area of pointer. And let's say I want to store address of these locations which are available in this area. So how I can write P0 equals to address of A0. P1 equals to address of A1 location. P2 equals to address of A2. And so on. Right? So let's say this is area A. Total 5 locations. And these are addresses. So 101 and 102 for this location because area is of integer type. So 2 bytes, then 2 bytes, 2 bytes, 2 bytes and 2 bytes. Two different addresses will be available for each location. Let's say this is area of pointer, which is P. So P0 will be having address of A0. So A0 location is this. It's address is 101, which will be stored inside P0. So P0 will be having address of A0 location, that is 101. Right? So in this area, in this area of pointer, we will be having addresses of all the locations. So through this area of pointer, we can access the values which are stored inside this edit without using name A. Right? So this I told you like how we can store different addresses of A. But if you have different variables in place of this, if you have different variables A, B, C, D, E, 5 variables at 5 different locations. So I'm removing this and this. And let's say you have A at this location. You have B at this location. You have C at this location. So this way, you have 5 different variables and different addresses. Right? And you want to store them practically into a pointer. So then you can convert that pointer into edit pointer. And here you can write like this. So this way, 0 index will be having 101. 1 index will be having 201. Then it will be having 301, 401. And it will be having 0.0. So this way, in this area of pointer, you can store all different addresses together and you can use this area of pointer for accessing their values. So you can apply a loop on this area. So you will be having these addresses. And if you dereference those addresses, then you will be having the values which are inside. Right? And I already told you how you can dereference that. So if you write P0. So P0 will provide 101. So what do you need to do? You need to write this. Asterisk P0. And further, you can put I here, apply a for loop. And with this way, using asterisk PO5, you will be having values of all these different, different locations. So this way, we use area of pointer so that we can store addresses of different locations into a single pointer. So again, I am summarizing this. So pointer can store address of one variable. Pointer to pointer can store address of pointer variable. And area of pointer can store multiple or different location addresses all together into a single pointer. So this way, I hope you understood a basic idea related to these key points. And I hope you explain you understood whatever I explained in this video. And if you want to watch more videos related to pointer. So at the end of this video, you can have a link of playlist that is related to pointer. Also, you can go to description of this video. So there you will find links of various playlist related to key language. So you can follow them and watch videos related to C programming and learn them easily. So I hope you understood whatever I explained. Thank you for watching this video.