So now let's create a code that we learned in previous lectures.
So we're going to firstly initialize an array length here.
So in this case, the array length is going to be five or our array length or let's actually write it
like that.
My array length is going to be five and we will initialize a pointer to hold an array.
So integer here, new integer, it's going to be my array length and after that.
We will enter our arrays one by one, actually.
Why did this happen here?
We will initialize one by one.
Let me actually decrease the size.
Yeah, it's okay.
And here, make it.
Under like that.
So here now we will initialize it at the array.
So firstly 21, then 47, 87, 69 and 35.
Lastly here, decrease the size a little bit again.
Yes.
Here.
So actually, let's delete all of this and write our code.
So now we're going to firstly create the 21.
47.
87.
35 and 92.
Or actually, we did a mistake here.
So, uh, 47, 87, 69 and 35.
And here we will display each element by incrementing the pointer.
We will do this with p plus, plus, plus plus here.
So C out.
Using here.
We will notify that to the printed user that using pointer increment here.
Call the columns here in line and here we will use the pointer increment.
And in line here.
And line and will also print the value.
Value and address.
So T is going to be like make this spaces like five spaces in this case.
So t address you can also write it like this so you will see what t format specifiers do here.
So here in line actually you did learn.
Learned about T in previous lectures, as I remember.
But here.
While our Peter is true, then the sea out.
Peter.
Yeah, it's going to be t or not here.
New tab here and see out the tr and here, as you can see here, it's the first is pointer and this
is the without this asterisk here.
The second is without this asterisk here and inline and now we're going to increment the TR by one.
Here and we will need to move it back here.
So after the closing the braces of while loop, we will add we will make it a equals minus five here
and then we will display each element value by accessing pointer index.
In this case is a Peter this here pointer index.
And now we're going to see out here using pointer index oops here, uh, using pointer index and end
line.
And after that, see out.
The value and web address.
So it will make a space here, in this case, five character spaces here and end line.
And we will create a for loop in for integer equals zero.
Sign e to zero here while our e is less than our my array length, then increment e by one.
And inside this, we're going to print some PR index here.
So Peter versa without the asterisk here.
Peachtree.
And here it's going to be the tea here.
And after that, see out.
This and operator And here.
End line here.
So now let's actually build and run our application class G++ main.cpp dot exit.
And here.
So if we will run this code, we will get you will get this error here.
And this is not an error actually, uh, for sorry for mispronouncing it.
This is you will get this output here.
So as you can see in this here, we can access each element of the pointer array using the pointer increment
and using the pointer index here.
So, uh, and as you can see here, these are the same because they are the same object that resides
in the same memory here.
So these, all of them are the same.
However, if we use the pointer increment V so the first here, if we use the pointer increment.
We have to remember that after increasing the pointer, it will no longer hold the address of the array.
The solution is that we need to decrement the pointer again so like we did in this code here.
So we did decrement our pointer again here.
Actually.
And as you can see here, we decremented our pointer again.
That's our lecture and see you in the next lecture.