Hi, everyone.
Welcome back to the cause.
So today we will learn a new topic called Dear Friends Fence Operator.
So.
Intake was 10.
And Star B equals and by sendoff, Delphi.
See out.
Address off.
I see out.
See out.
See out defense be.
So let's see where the real output of each line.
So what this line will do?
I will get four bytes of memory space.
Let's say the addresses 700 and the value is.
And this is my symbol table.
So there is a variable eye and it's memory addresses.
700.
So what this land will do?
I will get a pointer B days for bites.
It will restore 700 basically and resolve.
And let's say it addresses 900.
Those days are variable B, there's a point to B, and it addresses nine entered.
See out at so if I some output will be 700 C out B.
So B is 700.
B is containing 700.
So 700 C yesterday.
I will go.
Plus I will go towards the symbol table.
Yes, there is a variable.
I and the variable I is stored at memory location 700.
So I will go to memory location seven ended and the value is ten.
So my output here will be ten.
Now this is something new.
This is something new that we have not seen before.
So this operator is called Dereference Operator.
So what it will do.
It will go to first of all, I will go to various be stored.
So peace to that memory location.
Nine hundred.
So I will go to 900.
Then memory addresses.
So when I did so, I wouldn't go to seven ended.
And then I will print this value.
So basically 10 will be printed here.
Ten.
And then.
OK, so ampersand A and B Botel, same eye and defense.
B, they both the same.
OK, so let's see with the help of an example then I will expand it further.
So I have a variable eye, which is 10 now letters.
That does create a pointer B, which will store the address of A.
Now, let us try to bring the value of high.
And let us also pride to print, also tried to lead offense be.
So what I want to say is the output of line number nine and line number 10 is seam that is then.
So our would coming out to be same Ben and Ben.
So what this line is doing.
Bromates.
Memories.
So an.
Value is.
What this line will do.
Pointer is a four bytes in my system.
It is starting so ended and let's say its addresses, 800 Soucy out.
I means print.
Then with the help of symbol, they will not be in a frenzy.
So this is pointing towards this.
This is a pointer it this pointing towards I so point Burpee is pointing towards.
I did a fence means go to that memory, location and print whatever is stored in it.
So my output will be 10.
OK, so one more time.
I have four bytes of memory space values, 10.
And it's doses seven.
I have, again, four bites of memory space.
This is a pointer, B, it's Ducey's, let's say 800.
And it is pointing towards this.
So when you will try and print the reference B or B, reference B meaning.
So the meaning of the defense B is go to the memory location and print the content.
So that's why Dennis printed here.
OK, so.
Now, a little sprint, and this is so she out and densify.
See out B.
So the output will be seem so big because B is containing the address of I only.
OK, so here will be an online.
So there this is the same.
Now, you can also change the venue, for example, I equals 23.
So if you will bring the value of I
ordered will be 23, the value of you has been changed.
Certain degree, you can also change the way you're fighting with the help of pointer.
So did a fence be it was 32.
And now let us spend the value of AI again.
So now the value of AI is 32.
So the value of AI is hard to do.
Now let's see how it happens.
So we have to focus on these lines.
OK, so I equal day three and Defense B equals 32.
So first of all, what I will do, I will search in the symbol table.
So there is a variable I and the variable I has got to memory this of 700.
So this is memory at this seven hundred and the value is initially ten.
So I will go to this memory this and I will change its value to 23 and here twenty three will be printed.
Now let us focus on this line.
So what will happen first of all?
I will go into Simbel Table and search for P.
Yes.
There is a point.
Turpie Its memory at this is 800.
So what I will do, I will.
So this is a pointer letters.
This is 800.
And the value stored is 700.
So I will reach here since it's dear friends.
So what I will do.
This is pointing towards this remote location.
So I will come here.
And I will change its value to try to do so at this line.
32 different.
OK.
So what I want to say is we have to raise.
To access.
Team memory.
We have two ways to access the same memory.
First is with the help of variable eye.
And second, with the help of point therapy, basically the offense be so I question D3 star be equipped
to do, too.
They both have the same eye and Dabi, they both had same, if you will, change any of them.
That will change the visual inflected input.
OK, so we have two ways to access the same memory.
First, with the help of Variable I.
And second, with the help of Pointer B..
Both are pointing towards the same memory location.
OK, so now let's see.
Some predict the output equation.
So this is a.
We have to predict its output.
So we can take our time.
You can post a video if you want to.
So now let's see what will be our output.
So.
This is a the value is seven and let's say the memory addresses 700.
OK.
So I have B. Ray Lewis, 17, and let's say the memory addresses 800.
I make a pointer which is storing their does B, so I have a point.
I see it distorting the address of B.
And let's say it's our business 800.
So, dear friends, C, quiz seven.
So go ahead.
Make it seven.
I'll see you out A and B..
So A seven B is seven.
So seven and seven.
This is Malverde.
So seven and seven.
Now C is containing the Sophie.
So C is containing the address of A.
Now, go to that memory location, did a fancy go to that memory location and change its value to 17.
So nowadays, 17.
To be out and then be so is 17, B is seven.
So this should be my output.
Seven seven, 17, seven.
OK, so let's see.
So seven seven seven deden seven.
So our prediction is hundred percent correct.
Now let's see when McCuistion.
So this is our question.
If you want to take some time, you can take.
You can post the video.
So let's see the solution.
OK.
So.
I have a variable, a very loose 50, and let's say it's Airbus's 700.
Now I have a point that BTR, so I have a pointer.
Its name is BTR.
And Distorting the air does Sophie.
That is seven 700.
Now, I have again appointed you.
So I have a point.
Q Let's say the memory does of PDR is 800.
So I have a point.
Q It's value copy the value of BTR.
So it is 700 starky plus plus.
So basically dereference so go to that memory location.
I have reached here.
Stargell means 50.
So 50 plus plus.
So it will become 51 C out a.
So 51.
And percent of P.D.A 800, their best of breed, are at this off.
Q So let's to their dose of QE is nine hundred.
So output will be nine hundred.
So this will be output.
These two are no loose.
OK, so one common thing that many people confuse here is this line line embedded.
And Star Q equals.
So many people will get confusion here.
So.
When I write and equals me.
So what will happen?
The value of B will be copied into A.
So if and B question and B questions, the value of A will also become.
Then basically copy the value of being to a.
Because both are of type integer here.
Both are of type.
And star, BTR, a quiz and person off a show here copy the valley of BTR in to kill because both are
of type in star.
So that's why I go.
But that's why I copied the value.
So I went in there and took.
Q OK, so this is my output.
Fifty one and two.
No lose.
So let's see.
So 51 and do it, and I may lose two eggs or decimal numbers.
OK.
If you will.
Brian.
Brenda Veli of Dead and Guillard output will be same.
They will lose seem.
They brought us doing their dose of a.
So we'll see you out there, Sophie.
Now, all these tea lines.
Well, today, N14 will have the same output.
That is the address of a.
You can see here the address of a.
So now.
So here we have three ways here.
We have three ways to access the same memory.
Three ways to access the same memory.
First, with the help of variably equals 10 seconds with the help of variable PDA.
So any PDA equals twenty powered with the help of another point.
Q So.
And you start.
Q was 30.
So if add this line, you reprint the value of it.
So the output will be 30.
OK.
So in this question, we now have three ways to access the same memory.
So this is a.
Pointer BTR is pointing towards this and Pointer Gill is also pointing towards this memory location.
OK.
So let us even more question.
So we have to predict its output.
Again, you can again you can post the video if you want to take some time.
Now let's see the solution.
So end equals 50.
OK.
This is a this is 50 and let's say it addresses seven and.
OK, so make a point that P.D.A, this point, WDR, is pointing towards this.
And so this is BTR site seven hundred and let's say it's memory vs. 800.
Did a fence be so good to go here?
S plus, increase the value, it will become 51 C out A.
So if you will see our day after will be 51.
But headline number eight, Malverde will be 50 because it is post increment.
So in Naples, 50 C out A plus plus and C out A.
So at this line my output will be 50.
But at this lane my output will be 51 because this is post increment.
This is post increment.
And same is happening here.
Start with the edit is actually nothing but a only.
Okay, so I will go towards this memory location.
I will increase its value, but before increasing its value, I will print C out BTR.
This line, this statement will be executed first and then the value of it will be incremented.
So now output will be 50 and 51.
Fifty and fifty one.
So let's give in lane here.
So 50 and 51.
OK.
So now let us discuss the last topic of today's class.
So try to focus on the right to focus on this line.
Never did a fence and he got a big address.
So we will always initialize our point or do not.
So this is a very big line.
Let's try to understand what is the meaning of this line.
Okay, so tell me what will happen if I do.
Entergy.
See, algae, Waterloo output, some output will be a guy Habichuela.
I've got a vision, Deja.
OK.
So now tell me what will happen if I try and do and start B?
See, outby.
So what will happen?
I've got a major will we entered.
I've got a bit this will be printed.
OK, no doubt below.
Now, what will happen?
If I do build a fence, be it was, let's say, 50.
So what will happen?
And in the next lane, fired prior to print, the value of B, B defense.
B.
So what will happen?
Let's see.
So venue.
Dude, venue.
All right.
This line, what will happen?
This is a point B and distorting a garbage at this.
No outline, no, this.
What I am trying to do.
Go through that garbage address.
Go to the garbage.
This dead garbage memory location and write 50 dear.
OK.
This is very scary for entropy is containing a garbage address.
And what we are trying to do at this line go to get the garbage address and relative to the.
But this is very scary.
This memory, this address doesn't belong to us.
This might be a protected memory.
This might be Rome.
So what I'm trying to do.
Go to that garbage location.
Go to the garbage address and drive 50 there.
So this is very, very scary.
You should not do it.
We should never do it.
OK.
So what we will do, so we will always we will always initialise.
We will always initialize our point or do none.
So then I will create my pointer in Star P and the next line if I want to do this.
So we should never do this.
I've explained before.
So what do we do?
As soon as you create the pointer, either give it some ideas.
So option number one, they're given some address and option number two is if you don't know what is
their district desperately want to give.
To initialise it with an.
So meaning of this line is there is a point or B and this point B is pointing towards nothing.
This point is pointing towards nothing.
So if in the next lane.
They will do this.
It will give us added.
It will give us at it our system will crash.
Basically, what is the meaning of this line?
Go to hell and write 50, dear.
Very strange.
So this will give us at it.
And our system will crash.
And I want our system to crash.
We want our system to crash.
Because I am doing a very stupid thing.
If I do some stupidity, then I must get out of a crash.
Must appear segmentation fault must be dear.
OK.
So that is the reason we will always initialize our Lapoint of.
Okay.
So if you will not initialize our pointer with what will happen.
So here I was not initializing my point provisional.
So anything can happen.
Okay.
So but if I really initialize my point of it then I will get an error.
I will get an error.
Our system will crash.
Then I will come to understand.
All I did some stupidity.
OK.
So let's write code.
So suppose Entergy see LG, what will happen?
I've got a bagian deja will get printed
and Appointer, which is containing garbagey orders if you will print.
B, what will happen?
I've got a major.
This will get printed.
OK.
So let's see.
So random garbage in danger and a garbage at this.
So what I told you, we will always initialize our pointer with null.
So initialize our point provisionally.
Now, if in the next line I will if I will change the value of being if I am the referencing B.
Our system will crash.
There will be segmentation void.
Sally's system got crashed and something and it has caught appeared beard.
OK, so this is this segmentation for Dinamo Gold.
OK, so I hope now you know the meaning of this line.
Never did a fence and a garbage address.
So always initialize your pointer to null.
OK, so this is it for this video.
If you have any doubt, feel free to ask.
Thank you.