C_74 Pointers in C- part 4 | Pointer to Pointer (Double Pointer)

Jenny's Lectures CS IT
11 Aug 202125:05

Summary

TLDRThis video tutorial delves into the concept of pointers in C programming, specifically focusing on double pointers or pointers to pointers. The instructor begins with a review of basic pointers and operations before advancing to the double pointer concept. Through detailed explanations and visual memory representations, viewers learn how to declare, initialize, and use double pointers. The tutorial also covers practical examples and code demonstrations using VS Code, ensuring a clear understanding of how double pointers function and their importance in C programming.

Takeaways

  • 📌 Pointers are crucial in C programming for handling memory addresses.
  • 💡 The 'address of' operator (&) and 'indirection' operator (*) are fundamental to understanding pointers.
  • 🖥️ Pointers can store the address of another variable, enabling efficient memory management.
  • 🔄 A pointer to a pointer, or a double pointer, stores the address of another pointer, not a normal variable.
  • 📝 Declaring a pointer to a pointer involves using double asterisks (**), indicating two levels of indirection.
  • 🔧 Properly initializing pointers is essential to avoid incompatible pointer type errors.
  • 🖱️ Accessing the value of a variable through a single pointer uses one asterisk (*), while a double pointer uses two asterisks (**).
  • 🔍 Visual representation of memory allocation helps in understanding how pointers work.
  • 📊 The concept of pointers can be extended to multiple levels, such as triple pointers, to manage more complex data structures.
  • 💻 Practical examples and coding in an editor like VS Code solidify the understanding of pointers in C programming.

Q & A

  • What is the main topic of this video?

    -The main topic of this video is the concept of pointers in C programming, specifically focusing on pointer to pointer (double pointer).

  • What are the two operators discussed in relation to pointers?

    -The two operators discussed are the address-of operator (&) and the indirection operator (*).

  • What is a double pointer?

    -A double pointer, or pointer to pointer, is a special pointer that stores the address of another pointer.

  • Why is the concept of double pointers important?

    -Double pointers are important because they allow for more complex data structures and memory management techniques, such as dynamic memory allocation and manipulation of multidimensional arrays.

  • How do you declare and initialize a double pointer?

    -You declare a double pointer with two asterisks (**) and initialize it by storing the address of a single pointer. For example: `int **q = &p;` where `p` is a pointer.

  • What is the correct way to access the value of a variable using a double pointer?

    -To access the value of a variable using a double pointer, you use the indirection operator twice. For example, `**q` will give you the value of the variable that `q` ultimately points to.

  • What happens if you try to store an integer value directly into a pointer variable?

    -If you try to store an integer value directly into a pointer variable, it will give an error because a pointer variable should store an address, not a direct integer value.

  • How can you print the address of a pointer variable?

    -You can print the address of a pointer variable using the address-of operator (&) and the %p format specifier in printf, e.g., `printf("%p", &p);`.

  • What error will occur if you assign the address of a normal variable to a double pointer?

    -Assigning the address of a normal variable to a double pointer will result in an incompatible pointer type error because a double pointer should point to a single pointer.

  • How do you change the value of a variable using a double pointer?

    -To change the value of a variable using a double pointer, you assign a new value to `**q`, where `q` is the double pointer. For example, `**q = 25;` will change the value of the variable pointed to by `q`.

  • What is a three-level pointer, and how do you declare it?

    -A three-level pointer is a pointer to a double pointer, allowing for even more levels of indirection. You declare it with three asterisks (***). For example: `int ***r = &q;` where `q` is a double pointer.

  • How can you access a variable using a three-level pointer?

    -To access a variable using a three-level pointer, you use the indirection operator three times. For example, `***r` will give you the value of the variable that `r` ultimately points to.

Outlines

00:00

🔍 Introduction to Pointer Basics in C

The video begins by introducing the concept of pointers in C programming, explaining the basics of pointers, the address-of operator (&), and the indirection operator (*). It covers how to assign a pointer value to another pointer and emphasizes the importance of understanding pointers when dealing with memory addresses. The explanation includes visual aids to depict how memory allocation works for variables and pointers.

05:02

🔄 Understanding Pointer to Pointer (Double Pointer)

The video delves into the concept of a pointer to a pointer, also known as a double pointer. It explains that a double pointer is a pointer that stores the address of another pointer, not a regular variable. The explanation includes a detailed example, showing how to declare and initialize a double pointer. It highlights the importance of the data type in pointer declarations and how the compiler interprets these declarations.

10:05

💡 Practical Examples of Double Pointers

The video provides practical examples to illustrate the use of double pointers. It explains how to declare a double pointer and assign the address of a pointer to it. The example demonstrates the memory allocation for a double pointer and how to access the value of a variable using a double pointer. The explanation includes step-by-step instructions and visual representations to make the concept clear.

15:06

🔢 Multi-Level Pointers and Their Use Cases

The video extends the discussion to multi-level pointers, showing how to declare and use triple pointers (pointer to a pointer to a pointer). It explains the rules for assigning addresses in multi-level pointers and demonstrates how to access a variable's value using a triple pointer. The explanation includes examples of how to print addresses and values at different pointer levels, emphasizing the correct usage and potential errors.

20:09

⚙️ Implementing and Testing Pointer Concepts in Code

The video transitions to a practical coding session, where the concepts discussed are implemented in C using VS Code. It shows how to create a file, write code to declare and initialize pointers, and print variable values using single, double, and triple pointers. The session includes debugging tips, explanation of common errors, and how to resolve them. The video concludes with a summary of the importance of understanding pointers and their practical applications in programming.

Mindmap

Keywords

💡Pointer

A pointer in C programming is a variable that stores the memory address of another variable. It is essential for understanding memory management and efficient handling of arrays and structures. In the script, pointers are introduced with the 'int *p' declaration, where 'p' stores the address of an integer variable 'a'.

💡Address-of Operator (&)

The address-of operator (&) is used to obtain the memory address of a variable. This operator is crucial when working with pointers as it provides the address that the pointer will store. For example, in 'p = &a', the address of variable 'a' is assigned to pointer 'p'.

💡Indirection Operator (*)

The indirection operator (*) is used to access the value at the memory address stored in a pointer. This operator is also known as the dereference operator. In the script, '*p' is used to access the value stored at the address contained in 'p', which points to 'a'.

💡Pointer to Pointer (Double Pointer)

A pointer to pointer, or double pointer, is a pointer variable that stores the address of another pointer. This is used for more complex data structures and for functions that need to modify the value of a pointer. In the script, 'int **q' is an example of a double pointer that stores the address of pointer 'p'.

💡Memory Allocation

Memory allocation refers to the process of reserving a block of memory during the execution of a program. Pointers are heavily used to manage dynamically allocated memory. The script mentions memory allocation implicitly when describing how pointers store addresses of variables.

💡Dereferencing

Dereferencing is the act of accessing the value at the address stored in a pointer using the indirection operator (*). In the script, '*p' is used to dereference the pointer 'p' to get the value of 'a'. Similarly, '**q' dereferences the double pointer 'q'.

💡Hexadecimal Address

A hexadecimal address is a way of representing memory addresses in base-16. This format is commonly used in low-level programming and debugging. In the script, memory addresses like '0x850' and '0x1046' are examples of hexadecimal addresses.

💡Initialization

Initialization is the process of assigning an initial value to a variable at the time of declaration. For pointers, this often involves assigning a memory address. In the script, 'int *p = &a' initializes the pointer 'p' with the address of 'a'.

💡Dereference Operator

The dereference operator (*) is used to obtain the value stored at the memory address contained in a pointer. It is also referred to as the indirection operator. For example, in '*p = 25', the operator changes the value at the address stored in 'p' to 25.

💡Pointer Arithmetic

Pointer arithmetic involves operations like addition and subtraction performed on pointers. These operations are crucial for navigating arrays and other data structures in memory. The script discusses how pointers point to specific memory locations and how these locations can be managed.

Highlights

Discussion on basics of pointers in C, including the address-of and indirection operators.

Introduction to the concept of pointer to pointer, also known as double pointer.

Explanation of declaring and initializing pointers and pointer to pointer variables.

Visualization of memory allocation and how pointers reference memory addresses.

Clarification on the type of data a pointer can store and the importance of matching data types.

Detailed example illustrating how a pointer to pointer stores the address of another pointer.

Steps to declare and initialize a double pointer, using an example with variables int a, p, and q.

Explanation of accessing values through different levels of pointers, using indirection operators.

Demonstration of how to access and print variable values using single, double, and triple pointers.

Examples showing the errors and warnings that occur when incompatible types are assigned to pointers.

Introduction of a triple pointer and explanation of how it stores the address of a double pointer.

Steps to declare, initialize, and access values using a triple pointer.

Explanation of how to update variable values using single, double, and triple pointers.

Demonstration of printing memory addresses and values using pointers in different levels.

Encouragement to practice with double and triple pointers to understand errors and proper usage.

Transcripts

play00:01

so in the series of learning programming

play00:02

in c we are discussing pointers in C so

play00:04

far we have discussed some Basics about

play00:06

pointers and those two operator like

play00:08

address of and indirection operator in

play00:10

pointer as well as how to assign a

play00:13

pointer value to another pointer that we

play00:15

have discussed now in this video we'll

play00:17

see an extended concept of pointer that

play00:19

is pointer to pointer or in other word

play00:22

you can also say it's a double pointer

play00:24

so this concept is also very important

play00:26

when you deal with pointers right we'll

play00:28

discuss this with proper examp example

play00:30

we'll see a simple program also here we

play00:32

will try run that program here how like

play00:34

that program works everything we'll

play00:35

discuss and then I'll show you

play00:36

practically on my laptop using vs code

play00:39

editor right see before going to the

play00:42

pointer to pointer concept or the double

play00:44

pointer concept let me just recap this

play00:47

thing if I if I want to declare a

play00:50

variable like int a is equal to suppose

play00:52

10 right and if you want to declare a

play00:55

pointer then in Star p and pointer is

play00:59

going to to contain address of any other

play01:01

variable so I'm going to initialize this

play01:03

here only address of a right int SRI p

play01:08

means it means see in memory if suppose

play01:10

in memory this is our

play01:13

memory you can draw it horizontally or

play01:16

vertically it's up to you right and it's

play01:18

like you can say it's a long tape of

play01:20

bites something like

play01:22

this right now these are like one by 1

play01:26

by one by this kind of thing so in a is

play01:28

equal to 10 so somewhere memory would be

play01:30

to this a that is 4 by maybe suppose we

play01:33

have this this memory something like

play01:36

this and these four bytes from here 1 2

play01:38

3 4 these four bytes has been allocated

play01:40

to this a right and here I'm going to

play01:43

store

play01:45

10 like in 32 bits 10 would be you know

play01:48

this would be converted into binary

play01:50

digit like 0 and one in 32 bits and that

play01:52

would be stored here right so now this

play01:54

is for a and int star p is estri means

play01:59

obviously this would be a pointer this

play02:01

is Declaration of pointer or as well as

play02:03

initialization of this pointer so it

play02:04

will tell the compiler that P would be a

play02:06

pointer but obviously memory would be

play02:07

allocated to this what is size of

play02:09

pointer on a 32-bit machine it it would

play02:11

take four byte right so suppose here we

play02:14

have pointer these four by one 2 3

play02:17

4 1 2 3 4 these four bites would be for

play02:20

this P here we have p and here what

play02:23

would be stored address of a and suppose

play02:25

address of a is this this bite this

play02:27

address of a is suppose 1,000 1 th1

play02:31

1,2,3 so obviously we'll take Base

play02:34

address like the address of the first

play02:35

bite of this first address of the first

play02:38

bite that would be address of this a so

play02:40

now this th000 would be stored here

play02:42

right so this would be pointing to this

play02:44

memory location right so simp for

play02:47

Simplicity purpose I'm just drawing this

play02:49

thing like this here we have

play02:53

a somewhere in memory and location is

play02:56

address is th000 in a we have 10 right

play02:59

and one pointer we

play03:01

have p and suppose address of this is uh

play03:05

maybe I don't know what should be the

play03:06

address or I can say like

play03:08

850 maybe I mean address would be in

play03:11

hexadecimal form obviously right so now

play03:14

in P what we have address of a address

play03:15

of pH th000 so in P we have 1,000 so now

play03:19

p is pointing to this a something like

play03:22

this this would be the visual

play03:23

representation of this this thing right

play03:27

so now p is what a pointer to integer

play03:30

data type

play03:32

right type of this is int like if I

play03:36

write here type of this is like int star

play03:40

this thing you can say because this is a

play03:42

pointer so I think this thing is clear

play03:44

to you because this is going to be very

play03:46

important whatever data type you write

play03:48

here in the Declaration of this pointer

play03:50

this will

play03:52

tell this pointer is going to store or

play03:54

this pointer is going to point which

play03:56

data type of variable right means here p

play04:00

is going to store address of a variable

play04:02

whose data type is integer should be

play04:03

integer if your data type is float that

play04:05

would be illegal right I hope you got

play04:08

this now now what is pointer to

play04:12

pointer pointer two pointer means see

play04:15

this is pointer to

play04:18

variable right pointer to variable it

play04:21

means this pointer is going to store

play04:22

address of this variable if I say

play04:24

pointer to

play04:26

pointer

play04:28

means a point pointer to pointer is or

play04:31

you can say double pointer is a special

play04:33

variable or special pointer which is

play04:35

going to store address of another

play04:39

pointer right not any ordinary or normal

play04:42

variable this double point is going to

play04:44

store address of other pointer variable

play04:48

so if I take here suppose Q I'm taking Q

play04:52

is another pointer and is Q is going to

play04:55

store it is pointer to pointer means it

play04:58

is pointer to suppose this

play05:01

pointer right it is not pointer to a

play05:04

normal variable it is pointer to pointer

play05:06

that is why it is double pointer right

play05:09

it is going to show

play05:11

level right so now here 1,000 so not

play05:15

th000 here address of P would be stored

play05:18

now address of this pointer is 850 so

play05:20

here it should be 850 and obviously it

play05:23

is a variable so it is also having some

play05:26

memory location suppose memory location

play05:27

is

play05:28

1046

play05:30

right so now Q is here double

play05:33

pointer Q is pointer to a

play05:37

pointer to variable so now how to

play05:41

declare this Q

play05:44

see

play05:46

in if I want to declare q and in Q I'm

play05:49

going to store address of obviously P so

play05:53

now first

play05:55

thing Q is also a pointer right and S

play05:59

will tell the compiler in in the

play06:01

Declaration estri will tell the compiler

play06:03

that it is a pointer so definitely one

play06:05

estri would tell that Q would be a

play06:08

pointer right now Q is going to store

play06:11

address of a pointer variable so here

play06:14

data type which type of data type you

play06:17

will use whose address this Q is going

play06:20

to store so Q is going to store address

play06:22

of this

play06:23

P so here data type what you will write

play06:26

int SRI int

play06:31

SRI that is why here we are having two

play06:33

estri in double pointer I hope you got

play06:36

this concept why double estri here right

play06:40

here estri will tell it is single level

play06:43

pointer estri will tell this this is a

play06:44

pointer and int will tell data type of

play06:47

this variable so here this estc will

play06:49

tell that Q is pointer obviously Q is a

play06:51

pointer because it is storing address

play06:53

but it is storing address of a pointer

play06:55

variable so a data type you can write

play06:58

here we have have to tell here the type

play07:01

which type of address it is going to

play07:02

store so that should be in

play07:05

Star right so I hope you got this thing

play07:08

or you can say it is having what two

play07:10

level

play07:12

pointer right so now what you can say

play07:15

how you can initialize it it will

play07:16

contain address of another pointer that

play07:19

is

play07:21

p if you write here address of

play07:24

a it would be illegal right it will give

play07:28

some warning message

play07:30

incompatible know pointer type because a

play07:32

is what normal variable and it is double

play07:34

pointer so according to the rule it

play07:36

should contain address of a pointer

play07:39

variable only right so here we must

play07:42

write any pointer variable that is p now

play07:46

this is correct I hope you got now what

play07:49

is double pointer right now see if you

play07:52

want to print value of

play07:54

a how you can print a is equal to I'm

play07:58

going to print you using three methods

play08:00

so three percentage I'm writing here

play08:03

either you can write here

play08:05

what here I'm writing a so that will

play08:08

also give 10 or you can access it using

play08:10

this pointer also how you can write

play08:13

estri

play08:15

P estri IND Direction operator here it

play08:18

will act as IND Direction operator but

play08:19

here it is not IND Direction operator

play08:21

right because it is Declaration of

play08:23

pointer so here we have already declared

play08:26

after that if you use this one this

play08:28

thing then it will act as Direction

play08:29

operator or D referencing operator so

play08:31

value at this address right it it will

play08:33

also give 10 but if you want to access

play08:37

using this Q using this double pointer

play08:39

then how you will access C if I

play08:43

write s

play08:45

q it means estri q estri q means Q is

play08:51

what having address of p in Q we have

play08:56

850 that is address of P so so it means

play09:00

this will tell value at this address and

play09:04

address of p is

play09:06

850 so it will give value at 850 value

play09:09

at 850 is

play09:12

1,000 but that that's not we want we

play09:15

want value of

play09:16

a so we want value at th000 this is

play09:21

again address so again put ack here at

play09:26

that time it will give 10 value at 1,000

play09:28

would be 10 so here means it will we

play09:31

will

play09:33

use two in Direction operator because it

play09:36

is obviously it is of it is you can say

play09:38

it's of two level pointer so for

play09:41

accessing this value firstly we will go

play09:43

here then we will go here so one estri

play09:45

we will use then we go here another

play09:47

estri we use then we'll go here right so

play09:51

see here one more estri we have here one

play09:54

morec we have so value at 850 is

play09:58

1,000 one more stric value at th000 is

play10:01

10 so finally it will give 10 so using

play10:04

double pointer also you can access this

play10:06

a I hope now you got the concept of

play10:09

double pointer and same you can increase

play10:12

this level

play10:13

also right if I want to uh know store

play10:17

address of the

play10:18

skew suppose I'm taking one more

play10:21

variable uh PQ

play10:24

R and here I want to store address of

play10:26

this q that is 1046

play10:29

so it should point to here and suppose

play10:32

address of this is

play10:34

2046 so now Q is what pointer to pointer

play10:40

two pointer two variable it is having

play10:44

three level 1 2 and

play10:47

3 right it means how you will declare

play10:53

this

play10:54

in so now obviously R is a pointer

play10:57

variable because it is any address so

play11:01

this 1 s trick will tell the compiler

play11:04

that it is a it is what pointer type of

play11:07

variable whose address it will

play11:10

contain Q so Q type in general if you

play11:14

write like this would be

play11:16

int

play11:18

estri

play11:20

estri right because it is also

play11:23

containing this address address of a

play11:25

pointer and then variable so here we

play11:27

will write two s one and again one so

play11:32

it's of three level so here we can store

play11:34

address of

play11:36

Q if you want to store her address of

play11:40

P that would also be

play11:42

illegal right because 1 2 three three

play11:47

level pointer or in short in shortcut or

play11:49

in simple term you can say it is three

play11:52

level pointer so it can store according

play11:54

to the rule address of two level pointer

play11:56

two level pointer is Q so according to

play11:59

the rule it should store address of Q if

play12:02

a two level pointer it should store

play12:04

address of one level pointer if a one

play12:06

level pointer it should store address of

play12:08

zero level because a is what obviously

play12:11

zero level having zero level it is

play12:13

having one level it is two level it is

play12:14

three

play12:15

level

play12:17

right so I hope you got this and using R

play12:21

if you want to access a then how you can

play12:25

access 1 2 3 and R here you can write

play12:31

this thing see how you will get this

play12:34

thing SRI SRI estrick and R is what

play12:39

address of Q address of Q is

play12:44

850 first of all this one then this one

play12:48

and then this you can write this also

play12:51

but better to write here the level in

play12:54

Brackets this and this it's a good

play12:57

practice what one bracket something like

play13:00

this right this is also fine without any

play13:03

brackets so first this star value it

play13:07

means it will give value at this address

play13:10

whatever the address return to the next

play13:12

of this star so estri estri and what

play13:17

this will give value at 850 value at

play13:19

850 value at 850 is oh not 850 see R is

play13:25

what address of Q address of Q is 10

play13:30

46 right in R we have 1046 so value at

play13:33

1046 is 850 so this will give

play13:37

what

play13:39

850 now this SRI value at 850 value at

play13:43

850 is 1,000 so it will

play13:45

give 1,000 so now this s value at th000

play13:49

is 10 so it will give 10 so finally

play13:51

answer would be 10 this is how you can

play13:54

access the variable using three level

play13:57

pointer right and if you want to store

play14:00

if you want to you know change this

play14:02

value using these double pointer and

play14:04

this

play14:05

pointer then how you can write if you

play14:07

write something like

play14:10

this if I write here estri estri Q is

play14:14

equal to

play14:16

25 and now I want to print value of a

play14:19

then what should be the answer C estri

play14:21

and EST Q it means what you are

play14:24

accessing this 25 would be stored where

play14:26

the s q means value at Q in Q we are

play14:30

having 850 so value at 850 is value at

play14:34

850 is 1,000 then again here would be

play14:37

th000 but this star we also have then

play14:40

value at th000 is 10 so ultimately we

play14:44

are accessing this and here we are going

play14:46

to show 25 so if you want to print a now

play14:49

then it would be

play14:50

25 right but but see here I'm writing

play14:55

here I'm writing this is question for

play14:57

you rather than this I'm just writing s

play15:00

q is equal to 25 what would be the

play15:03

answer if you will print a then what

play15:06

would be the answer or where this 25

play15:07

would be stored or it it will give any

play15:09

error or it is illegal or not that you

play15:11

have to tell me in comment box right I

play15:14

think it it is illegal it will give some

play15:16

error why so see EST Q means value at q

play15:21

q is what Q is containing 850 so SRI 850

play15:26

Q is what pointer to pointer so when

play15:28

value at

play15:29

850 value at 850 is 1,000 and here I

play15:33

want to store

play15:34

25 but here it is containing

play15:38

address so directly we cannot assign any

play15:41

integer value here in any pointer this

play15:44

would be invalid incompatible type of

play15:47

error it will give right because the

play15:50

here the DAT type is or you can say here

play15:52

this type of this is what in Star but

play15:55

you are going to assign integer only

play15:57

that would be illegal

play15:59

right so it will give error fine now see

play16:04

you have to assign this Q value using

play16:07

this R pointer that you have to do right

play16:13

you have to change this value to

play16:15

50 but using this pointer R how you will

play16:19

change it and how you will print that

play16:22

thing you have to tell me in comment box

play16:23

right so I guess this is not very tough

play16:25

you got the concept pointer two pointer

play16:27

or double pointer and why we are writing

play16:29

this this double pointer and using

play16:31

double pointer also how you will access

play16:33

the variable value of that

play16:36

variable right so now let me show you

play16:38

practically this thing so now let me

play16:41

create a file

play16:42

here I'm taking

play16:46

name double pointer do c

play16:53

right header file and then we'll write

play16:56

main function and here I'm going to take

play16:59

a variable in a is equal to 10 and here

play17:03

I'm taking a what single pointer first

play17:06

of all right in single pointer we can

play17:09

store address of a normal variable right

play17:12

address of a and here I want I'm

play17:15

declaring double pointer suppose q and

play17:17

in double pointer I'm initializing we

play17:19

can store according to the rule address

play17:21

of any pointer variable so here we have

play17:24

P pointer variable right so now uh

play17:30

just

play17:31

print a a is equal to percentage

play17:35

D and

play17:38

uh we are printing value of a

play17:42

here using simple a or another method is

play17:46

you can also print a is equal to

play17:49

percentage D and using pointer single

play17:52

pointer so estri

play17:54

P that's it right and one more more

play17:58

method is obviously we can also

play18:01

access this variable using double

play18:04

pointer also right it's a chain of

play18:06

pointer right print

play18:09

F or you can say it's

play18:13

like of a right obviously if you have

play18:16

relative it's D relative but then also

play18:20

anyone who knows your D relatives then

play18:23

he or she can also access you through

play18:26

those dur relatives right I hope hope

play18:28

you got my point so now a is equal to

play18:32

because you know these are Interlink

play18:34

pointer two pointer then two variable so

play18:37

percentage D and here how to access

play18:42

estri

play18:43

estri and

play18:47

Q

play18:49

right now let me print

play18:52

this what output it will give give C in

play18:56

three cases a is 10 it is is giving

play18:58

value of pH 10 so using double pointer

play19:01

also this is how you can access this a

play19:04

or if I write here see if I write here

play19:07

in s p is equal to um address of a I'm

play19:12

going to store address of a single

play19:14

simple variable normal variable and here

play19:17

let me just run this and see what

play19:19

happens see initialization of in star

play19:23

star it's like incompatible pointer type

play19:26

int Star right so it will give this type

play19:28

of error and it has stopped working so

play19:31

according to the rule we shouldn't do

play19:32

this

play19:36

right and see it is giving a 10 and a 10

play19:39

these two a and star B so that is not

play19:43

correct if a two Lev pointer it it can

play19:45

only store address of a one level

play19:47

pointer that is address of P right and

play19:50

here if I'm taking int three level

play19:53

pointer star star star

play19:56

r that according to the rule should

play19:58

contain address so for two level pointer

play20:00

here two level pointer is Q because it

play20:03

is having two estri

play20:04

right so that's it and using this also

play20:09

we can also access

play20:12

a a is equal to percentage D and uh here

play20:18

I'm accessing how three SRI sign we have

play20:22

to use right because it is three level

play20:24

pointer srick and here I'm using what

play20:30

R so this also will give you same result

play20:34

that is 10 see here a is equal to 10

play20:39

fine

play20:41

now another another thing what we can do

play20:44

is see

play20:46

here if you want to print if you want to

play20:49

print address of

play20:51

Q you want to print address of Q so

play20:55

address of Q is where in which pointer

play20:58

in r r is storing address of Q so if you

play21:02

print here print

play21:05

F address of

play21:08

Q in hexadecimal form I want to print so

play21:11

percentage uh X right and simply you can

play21:15

print R and that will give address of Q

play21:20

or if you want to print address of Q

play21:23

then you can also write address of

play21:25

operator and address of Q so here I'm

play21:28

writing two percentage x two times and

play21:31

that that should give same result right

play21:34

and suppose you want to print address of

play21:37

address of P now address of p is where

play21:40

in Q right

play21:43

so address of p is equal to address

play21:47

would be in exod decimal form and using

play21:50

two know method I want to print one is

play21:53

what address of Simply use address of

play21:55

operator so address of P it will give

play21:57

address of P or next thing is address of

play21:59

p is where in Q pointer Q is double

play22:03

pointer so simply you can print Q

play22:06

here that will also give address of P

play22:09

right so now let me save this and let me

play22:13

run this now what it will give

play22:20

see okay let me uh do what

play22:25

here it should be SL then you will get

play22:29

it better right see

play22:32

now address of Q is both are giving same

play22:37

result address of Q is either you can

play22:39

print r or address of Q obviously

play22:41

address would be same so it will give

play22:42

same result address of PS both are

play22:45

giving same 61 FC C4 fc4 right so this

play22:50

is the method either you can print

play22:52

address of P using address of p and or Q

play22:55

right address of R if you want toint

play22:58

print

play22:59

then then address of RS where is stored

play23:02

no we have no pointer which is going to

play23:05

store address of Q we haven't declared

play23:07

any pointer if you want to declare you

play23:09

can see like star star star star another

play23:12

pointer maybe you can say and take s or

play23:15

t or there you can store address of r

play23:18

four level pointer right or simply you

play23:20

can print here address of R using

play23:22

address of operator right and you can

play23:24

also see something like you can also do

play23:26

something like this if I write here star

play23:30

p is equal to

play23:33

2 right and after that I'm writing star

play23:37

star Q is equal to

play23:41

17 so according to what should be the

play23:43

final value of a see SRI p means value

play23:49

at p in P we have what address of a so

play23:52

value at that address is 10 so in a 12

play23:56

would be stored but again estri SRI Q

play23:59

this is also another way what to

play24:02

access value of a so now value of a

play24:06

becomes 17 so final value of a becomes

play24:08

17 so it should print 17 see

play24:17

now let me save it and again run it see

play24:21

now value of a 17 I hope you go we can

play24:25

update this thing or using this operator

play24:27

Al so like s star star star R and if I

play24:30

write here 78 now final value of a is 78

play24:34

because this also meaning of this is

play24:36

also same thing we are accessing value

play24:37

of a right I hope this is clear double

play24:41

pointer and you know level of

play24:43

pointers so you can also know practice

play24:46

these kind of simple simple problems

play24:47

using these double pointer and triple

play24:50

pointer and this kind of thing and you

play24:51

can print uh try to print values and

play24:54

variables and you can see what kind of

play24:56

error you are getting right so that's it

play24:58

for this video now so in the next video

play25:00

we'll see some another concept of

play25:02

pointers now I'll see you in the next

play25:03

video till then bye-bye take care

Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
C ProgrammingPointersDouble PointersMemory ManagementVS CodeProgramming BasicsCoding TutorialComputer ScienceData StructuresVariable Declaration
¿Necesitas un resumen en inglés?