1 00:00:00,850 --> 00:00:05,740 So now let's create a code that we learned in previous lectures. 2 00:00:05,740 --> 00:00:09,880 So we're going to firstly initialize an array length here. 3 00:00:09,880 --> 00: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 4 00:00:18,850 --> 00:00:19,180 like that. 5 00:00:19,180 --> 00:00:25,300 My array length is going to be five and we will initialize a pointer to hold an array. 6 00:00:25,300 --> 00:00:34,870 So integer here, new integer, it's going to be my array length and after that. 7 00:00:35,950 --> 00:00:40,870 We will enter our arrays one by one, actually. 8 00:00:40,870 --> 00:00:43,210 Why did this happen here? 9 00:00:44,900 --> 00:00:48,140 We will initialize one by one. 10 00:00:48,140 --> 00:00:50,450 Let me actually decrease the size. 11 00:00:50,450 --> 00:00:51,650 Yeah, it's okay. 12 00:00:51,830 --> 00:00:53,540 And here, make it. 13 00:00:55,840 --> 00:00:57,030 Under like that. 14 00:00:57,040 --> 00:01:00,940 So here now we will initialize it at the array. 15 00:01:00,940 --> 00:01:07,060 So firstly 21, then 47, 87, 69 and 35. 16 00:01:07,660 --> 00:01:11,950 Lastly here, decrease the size a little bit again. 17 00:01:12,730 --> 00:01:13,540 Yes. 18 00:01:13,810 --> 00:01:14,530 Here. 19 00:01:14,740 --> 00:01:18,550 So actually, let's delete all of this and write our code. 20 00:01:18,880 --> 00:01:22,540 So now we're going to firstly create the 21. 21 00:01:23,270 --> 00:01:24,410 47. 22 00:01:25,040 --> 00:01:26,060 87. 23 00:01:27,630 --> 00:01:29,550 35 and 92. 24 00:01:30,260 --> 00:01:32,850 Or actually, we did a mistake here. 25 00:01:32,850 --> 00:01:38,640 So, uh, 47, 87, 69 and 35. 26 00:01:41,340 --> 00:01:47,250 And here we will display each element by incrementing the pointer. 27 00:01:47,850 --> 00:01:50,890 We will do this with p plus, plus, plus plus here. 28 00:01:50,910 --> 00:01:52,380 So C out. 29 00:01:54,190 --> 00:01:55,060 Using here. 30 00:01:55,060 --> 00:02:00,370 We will notify that to the printed user that using pointer increment here. 31 00:02:03,640 --> 00:02:08,430 Call the columns here in line and here we will use the pointer increment. 32 00:02:08,550 --> 00:02:10,800 And in line here. 33 00:02:12,620 --> 00:02:16,130 And line and will also print the value. 34 00:02:17,530 --> 00:02:19,660 Value and address. 35 00:02:19,660 --> 00:02:25,090 So T is going to be like make this spaces like five spaces in this case. 36 00:02:25,090 --> 00:02:34,540 So t address you can also write it like this so you will see what t format specifiers do here. 37 00:02:34,540 --> 00:02:38,470 So here in line actually you did learn. 38 00:02:38,590 --> 00:02:41,740 Learned about T in previous lectures, as I remember. 39 00:02:41,740 --> 00:02:43,390 But here. 40 00:02:49,010 --> 00:02:54,770 While our Peter is true, then the sea out. 41 00:02:56,270 --> 00:02:57,130 Peter. 42 00:02:58,330 --> 00:03:01,240 Yeah, it's going to be t or not here. 43 00:03:01,980 --> 00: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 44 00:03:12,610 --> 00:03:15,190 is the without this asterisk here. 45 00:03:15,760 --> 00:03:22,360 The second is without this asterisk here and inline and now we're going to increment the TR by one. 46 00:03:24,480 --> 00:03:27,840 Here and we will need to move it back here. 47 00:03:27,840 --> 00:03:38,610 So after the closing the braces of while loop, we will add we will make it a equals minus five here 48 00:03:38,610 --> 00:03:43,740 and then we will display each element value by accessing pointer index. 49 00:03:43,740 --> 00:03:47,400 In this case is a Peter this here pointer index. 50 00:03:47,400 --> 00:04:01,170 And now we're going to see out here using pointer index oops here, uh, using pointer index and end 51 00:04:01,170 --> 00:04:01,830 line. 52 00:04:03,210 --> 00:04:04,950 And after that, see out. 53 00:04:06,150 --> 00:04:10,200 The value and web address. 54 00:04:10,200 --> 00:04:15,990 So it will make a space here, in this case, five character spaces here and end line. 55 00:04:16,800 --> 00:04:21,990 And we will create a for loop in for integer equals zero. 56 00:04:24,020 --> 00:04:32,390 Sign e to zero here while our e is less than our my array length, then increment e by one. 57 00:04:33,510 --> 00:04:38,280 And inside this, we're going to print some PR index here. 58 00:04:38,280 --> 00:04:41,130 So Peter versa without the asterisk here. 59 00:04:42,000 --> 00:04:42,850 Peachtree. 60 00:04:43,230 --> 00:04:48,150 And here it's going to be the tea here. 61 00:04:49,170 --> 00:04:51,450 And after that, see out. 62 00:04:53,450 --> 00:04:55,970 This and operator And here. 63 00:04:57,830 --> 00:05:00,920 End line here. 64 00:05:01,310 --> 00:05:10,880 So now let's actually build and run our application class G++ main.cpp dot exit. 65 00:05:10,880 --> 00:05:12,260 And here. 66 00:05:12,620 --> 00:05:17,480 So if we will run this code, we will get you will get this error here. 67 00:05:17,570 --> 00:05:22,130 And this is not an error actually, uh, for sorry for mispronouncing it. 68 00:05:22,130 --> 00:05:24,020 This is you will get this output here. 69 00:05:24,020 --> 00:05:31,730 So as you can see in this here, we can access each element of the pointer array using the pointer increment 70 00:05:31,730 --> 00:05:34,610 and using the pointer index here. 71 00:05:34,610 --> 00:05:41,060 So, uh, and as you can see here, these are the same because they are the same object that resides 72 00:05:41,060 --> 00:05:42,860 in the same memory here. 73 00:05:42,860 --> 00:05:46,010 So these, all of them are the same. 74 00:05:46,400 --> 00:05:54,350 However, if we use the pointer increment V so the first here, if we use the pointer increment. 75 00:05:55,260 --> 00:06:02,610 We have to remember that after increasing the pointer, it will no longer hold the address of the array. 76 00:06:02,640 --> 00:06:08,430 The solution is that we need to decrement the pointer again so like we did in this code here. 77 00:06:08,700 --> 00:06:14,790 So we did decrement our pointer again here. 78 00:06:15,820 --> 00:06:16,300 Actually. 79 00:06:16,750 --> 00:06:20,530 And as you can see here, we decremented our pointer again. 80 00:06:21,930 --> 00:06:24,570 That's our lecture and see you in the next lecture.