WEBVTT

00:00.850 --> 00:05.740
So now let's create a code that we learned in previous lectures.

00:05.740 --> 00:09.880
So we're going to firstly initialize an array length here.

00:09.880 --> 00:18.850
So in this case, the array length is going to be five or our array length or let's actually write it

00:18.850 --> 00:19.180
like that.

00:19.180 --> 00:25.300
My array length is going to be five and we will initialize a pointer to hold an array.

00:25.300 --> 00:34.870
So integer here, new integer, it's going to be my array length and after that.

00:35.950 --> 00:40.870
We will enter our arrays one by one, actually.

00:40.870 --> 00:43.210
Why did this happen here?

00:44.900 --> 00:48.140
We will initialize one by one.

00:48.140 --> 00:50.450
Let me actually decrease the size.

00:50.450 --> 00:51.650
Yeah, it's okay.

00:51.830 --> 00:53.540
And here, make it.

00:55.840 --> 00:57.030
Under like that.

00:57.040 --> 01:00.940
So here now we will initialize it at the array.

01:00.940 --> 01:07.060
So firstly 21, then 47, 87, 69 and 35.

01:07.660 --> 01:11.950
Lastly here, decrease the size a little bit again.

01:12.730 --> 01:13.540
Yes.

01:13.810 --> 01:14.530
Here.

01:14.740 --> 01:18.550
So actually, let's delete all of this and write our code.

01:18.880 --> 01:22.540
So now we're going to firstly create the 21.

01:23.270 --> 01:24.410
47.

01:25.040 --> 01:26.060
87.

01:27.630 --> 01:29.550
35 and 92.

01:30.260 --> 01:32.850
Or actually, we did a mistake here.

01:32.850 --> 01:38.640
So, uh, 47, 87, 69 and 35.

01:41.340 --> 01:47.250
And here we will display each element by incrementing the pointer.

01:47.850 --> 01:50.890
We will do this with p plus, plus, plus plus here.

01:50.910 --> 01:52.380
So C out.

01:54.190 --> 01:55.060
Using here.

01:55.060 --> 02:00.370
We will notify that to the printed user that using pointer increment here.

02:03.640 --> 02:08.430
Call the columns here in line and here we will use the pointer increment.

02:08.550 --> 02:10.800
And in line here.

02:12.620 --> 02:16.130
And line and will also print the value.

02:17.530 --> 02:19.660
Value and address.

02:19.660 --> 02:25.090
So T is going to be like make this spaces like five spaces in this case.

02:25.090 --> 02:34.540
So t address you can also write it like this so you will see what t format specifiers do here.

02:34.540 --> 02:38.470
So here in line actually you did learn.

02:38.590 --> 02:41.740
Learned about T in previous lectures, as I remember.

02:41.740 --> 02:43.390
But here.

02:49.010 --> 02:54.770
While our Peter is true, then the sea out.

02:56.270 --> 02:57.130
Peter.

02:58.330 --> 03:01.240
Yeah, it's going to be t or not here.

03:01.980 --> 03:12.610
New tab here and see out the tr and here, as you can see here, it's the first is pointer and this

03:12.610 --> 03:15.190
is the without this asterisk here.

03:15.760 --> 03:22.360
The second is without this asterisk here and inline and now we're going to increment the TR by one.

03:24.480 --> 03:27.840
Here and we will need to move it back here.

03:27.840 --> 03:38.610
So after the closing the braces of while loop, we will add we will make it a equals minus five here

03:38.610 --> 03:43.740
and then we will display each element value by accessing pointer index.

03:43.740 --> 03:47.400
In this case is a Peter this here pointer index.

03:47.400 --> 04:01.170
And now we're going to see out here using pointer index oops here, uh, using pointer index and end

04:01.170 --> 04:01.830
line.

04:03.210 --> 04:04.950
And after that, see out.

04:06.150 --> 04:10.200
The value and web address.

04:10.200 --> 04:15.990
So it will make a space here, in this case, five character spaces here and end line.

04:16.800 --> 04:21.990
And we will create a for loop in for integer equals zero.

04:24.020 --> 04:32.390
Sign e to zero here while our e is less than our my array length, then increment e by one.

04:33.510 --> 04:38.280
And inside this, we're going to print some PR index here.

04:38.280 --> 04:41.130
So Peter versa without the asterisk here.

04:42.000 --> 04:42.850
Peachtree.

04:43.230 --> 04:48.150
And here it's going to be the tea here.

04:49.170 --> 04:51.450
And after that, see out.

04:53.450 --> 04:55.970
This and operator And here.

04:57.830 --> 05:00.920
End line here.

05:01.310 --> 05:10.880
So now let's actually build and run our application class G++ main.cpp dot exit.

05:10.880 --> 05:12.260
And here.

05:12.620 --> 05:17.480
So if we will run this code, we will get you will get this error here.

05:17.570 --> 05:22.130
And this is not an error actually, uh, for sorry for mispronouncing it.

05:22.130 --> 05:24.020
This is you will get this output here.

05:24.020 --> 05:31.730
So as you can see in this here, we can access each element of the pointer array using the pointer increment

05:31.730 --> 05:34.610
and using the pointer index here.

05:34.610 --> 05:41.060
So, uh, and as you can see here, these are the same because they are the same object that resides

05:41.060 --> 05:42.860
in the same memory here.

05:42.860 --> 05:46.010
So these, all of them are the same.

05:46.400 --> 05:54.350
However, if we use the pointer increment V so the first here, if we use the pointer increment.

05:55.260 --> 06:02.610
We have to remember that after increasing the pointer, it will no longer hold the address of the array.

06:02.640 --> 06:08.430
The solution is that we need to decrement the pointer again so like we did in this code here.

06:08.700 --> 06:14.790
So we did decrement our pointer again here.

06:15.820 --> 06:16.300
Actually.

06:16.750 --> 06:20.530
And as you can see here, we decremented our pointer again.

06:21.930 --> 06:24.570
That's our lecture and see you in the next lecture.
