Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,180 --> 00:00:08,100
OK, so now what we are going to do is to talk about how we can declare a variable of some structural
2
00:00:08,100 --> 00:00:13,150
type we've that we've just defined in one of our previous videos.
3
00:00:13,170 --> 00:00:21,120
OK, so if you want some strict, easy way to understand the rules and how you can create a variable
4
00:00:21,120 --> 00:00:24,540
of a defined structure template, here it is.
5
00:00:24,810 --> 00:00:32,700
So first of all, you use this struct, OK, you first use the word struct, then you specify the template,
6
00:00:33,000 --> 00:00:40,740
OK, the template structure name that you want to use, just like we've created previously structured
7
00:00:40,740 --> 00:00:47,000
template point's structure, template daid and structure template address, for example.
8
00:00:47,070 --> 00:00:52,170
So for example, if we have let's wait a minute where it is here.
9
00:00:52,440 --> 00:00:54,980
Not a pen but a laser pointer.
10
00:00:55,200 --> 00:01:03,600
So basically if previously we had created our data structure and we want to create a data structure
11
00:01:03,600 --> 00:01:08,810
variable to declare it, what we are going to use is simply struct.
12
00:01:09,090 --> 00:01:12,820
OK, just like the formula written here.
13
00:01:12,840 --> 00:01:17,370
OK, so that this will be our that will be our formula.
14
00:01:17,430 --> 00:01:25,790
OK, on how to declare a variable struct and then what we are going to have is struct struct is OK,
15
00:01:26,190 --> 00:01:30,360
the structure name that we've just created in the previous video.
16
00:01:30,390 --> 00:01:37,970
OK, it was just something like struct Dade Curly brackets and it was in today int month and into year.
17
00:01:37,980 --> 00:01:43,680
OK, if you do not remember exactly what it was, you may go to the previous video and to make sure
18
00:01:43,680 --> 00:01:44,040
of that.
19
00:01:44,590 --> 00:01:46,410
And basically there you go.
20
00:01:46,420 --> 00:01:52,870
You have created two variables of struct date type, each of them.
21
00:01:52,890 --> 00:01:54,300
OK, we will take a look.
22
00:01:54,480 --> 00:01:56,550
Let's say just that my date one.
23
00:01:56,920 --> 00:01:58,620
OK, so that's the variable.
24
00:01:58,620 --> 00:02:07,410
And each of these variables contain is part of them are some integers, OK, which are just these smaller
25
00:02:07,410 --> 00:02:11,510
boxes representing the day, the month in the year.
26
00:02:12,150 --> 00:02:12,730
Awesome.
27
00:02:13,050 --> 00:02:14,550
So here you go.
28
00:02:14,550 --> 00:02:16,990
The variable name like this one.
29
00:02:17,010 --> 00:02:23,130
OK, so that's the variable we created in this variable is of type struct date.
30
00:02:23,130 --> 00:02:29,430
And we know that strike date is a template for structure with three fields.
31
00:02:29,580 --> 00:02:34,500
The first one is day, the second is month and the third is year.
32
00:02:34,510 --> 00:02:35,380
Amazing.
33
00:02:35,400 --> 00:02:42,960
So what we created is a new variable called My Date one with three fields.
34
00:02:43,200 --> 00:02:48,680
Just make sure that you notice that all of them are not yet initialized.
35
00:02:48,690 --> 00:02:54,960
OK, so we don't know what will be their values, just like you created in day, in month and in year.
36
00:02:55,110 --> 00:02:59,970
You don't know they are values that they are not yet have been initialized.
37
00:03:00,000 --> 00:03:00,810
All right.
38
00:03:00,810 --> 00:03:06,780
And now what I want to show you guys is how we can access to variables fields.
39
00:03:06,780 --> 00:03:11,580
So, for example, we created some variable of some new type.
40
00:03:11,580 --> 00:03:13,040
OK, where did it go?
41
00:03:13,350 --> 00:03:18,030
So we created this variable, my each one with these three fields.
42
00:03:18,030 --> 00:03:24,270
And let's think of these might add one is a variable in new box, bigger box that contains three smaller
43
00:03:24,270 --> 00:03:29,250
box, smaller boxes as part of a date, day, month and year.
44
00:03:30,030 --> 00:03:40,470
So we have these inner boxes that we said that they are if we talk officially, these are just the fields
45
00:03:40,470 --> 00:03:41,970
of this structure.
46
00:03:42,450 --> 00:03:48,570
So these variables, which are part of the bigger box, can be thought of smaller boxes.
47
00:03:48,600 --> 00:03:51,150
OK, I'm just saying it once again.
48
00:03:51,150 --> 00:03:58,260
Think of this simple analogy and your life will be much easier just in the terms of programming again
49
00:03:58,290 --> 00:03:59,280
and in this course.
50
00:04:00,120 --> 00:04:03,610
But you understand these concept of boxes.
51
00:04:03,930 --> 00:04:10,500
Trust me, guys, I I've taught a lot of students how to code and this analogy really works.
52
00:04:10,920 --> 00:04:19,410
So if you let's go back to our EXIS if you want to access one of these fields, OK, we know that currently
53
00:04:19,410 --> 00:04:22,890
they are not initialized one of these inner boxes.
54
00:04:22,890 --> 00:04:29,040
If you want to access them, then it can be done just by using the dot notation.
55
00:04:29,040 --> 00:04:31,920
So first of all, you specify the variable name.
56
00:04:31,920 --> 00:04:37,260
You know that the variable name is not date, OK, it's not strike date.
57
00:04:37,380 --> 00:04:40,530
Let's just refer it to destruct template.
58
00:04:40,860 --> 00:04:44,820
We know that the variable name in this case is my date one.
59
00:04:45,090 --> 00:04:46,290
So we specify my date.
60
00:04:46,290 --> 00:04:53,160
One thought, OK, you put this point and you specify the field name and you know that by looking if
61
00:04:53,160 --> 00:04:59,670
you're going to look at the structure template, you can see there every time you are going to use my.
62
00:05:00,060 --> 00:05:08,670
You always can see any of the exact fields that a given structure has, so you know that this structure
63
00:05:08,670 --> 00:05:16,890
might each one is of a date structure type and date structure type consists of three fields, day,
64
00:05:16,920 --> 00:05:18,150
month and year.
65
00:05:18,540 --> 00:05:22,770
So we are going to specify this field, whatever we want to access.
66
00:05:22,770 --> 00:05:28,590
For example, if we want to access the day, we can specify it here, the month, the year and so on.
67
00:05:28,620 --> 00:05:32,330
So finally, let's make this example.
68
00:05:32,340 --> 00:05:39,410
So might each one variable name dot de the name of the field equals to ten.
69
00:05:39,450 --> 00:05:46,940
We are basically going to this variable to the field of date and put value of ten inside.
70
00:05:46,950 --> 00:05:51,380
So my date one that month month equals to three.
71
00:05:51,600 --> 00:05:53,160
You're going to do the same.
72
00:05:53,490 --> 00:05:58,330
Might each one dot year you you're going to put here the value of fear.
73
00:05:58,500 --> 00:06:06,870
That's basically how it works, that that's basically how you access any of the fields of a given variable
74
00:06:06,870 --> 00:06:09,450
of some structure template.
75
00:06:09,540 --> 00:06:18,480
And we know that if we can read and access some values, OK, from a given place, we can basically
76
00:06:18,480 --> 00:06:23,340
use also the print command to print the values to the screen.
77
00:06:23,400 --> 00:06:30,180
OK, so for example, if you want to print these values through the screen, you may use like something
78
00:06:30,180 --> 00:06:30,720
like that.
79
00:06:30,720 --> 00:06:33,320
Let's just put it here where it is.
80
00:06:33,450 --> 00:06:33,880
Come here.
81
00:06:33,930 --> 00:06:39,630
OK, so you may go like print F, OK, so print F specify here.
82
00:06:39,630 --> 00:06:41,960
I don't know, percentage D, OK.
83
00:06:41,970 --> 00:06:45,830
And instead of that percentage then you may specify this value.
84
00:06:45,870 --> 00:06:48,180
OK, for example, if you want to print the day.
85
00:06:48,180 --> 00:06:57,480
So you specify my date one dot date here and it will be replaced in with this placeholder of percentage.
86
00:06:57,900 --> 00:07:03,360
So that's how you, how you print the value since you know how to access it.
87
00:07:03,390 --> 00:07:10,050
And also since you know how to access a given, let's say, sale inside of this in a given field inside
88
00:07:10,050 --> 00:07:15,690
of this variable, you can also use a scanner function to read values from the user.
89
00:07:15,870 --> 00:07:21,120
And what you are going simply to do if you want to like to read the given a value from the user and
90
00:07:21,120 --> 00:07:24,330
to place it inside of this field of the day field.
91
00:07:24,480 --> 00:07:32,010
So you specify second half percentage there and just use an ampersand here before the value you want
92
00:07:32,010 --> 00:07:33,780
to access to to feel it.
93
00:07:34,050 --> 00:07:39,720
So my suggestion to you guys is make sure that you understand everything that we spoke about in this
94
00:07:39,720 --> 00:07:47,220
video and also make sure you open up your I.D. and give it a little bit of practice and run a couple
95
00:07:47,220 --> 00:07:53,730
of commands and make sure that you can see everything is it should be so until next time.
96
00:07:53,730 --> 00:07:54,890
Keep on practicing.
97
00:07:54,900 --> 00:07:56,670
Keep on moving forward.
98
00:07:56,670 --> 00:08:01,440
And guys, you are bound to succeed him and wish you a good day.
10013
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.