Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,390 --> 00:00:06,510
What is going on, guys, so in one of our previous challenges and practices, I've shown you this example
2
00:00:06,510 --> 00:00:08,670
of how you can run some code.
3
00:00:09,000 --> 00:00:16,350
And also in the previous video where we talked about typedef structures, I've shown you two examples
4
00:00:16,350 --> 00:00:23,250
of using the print date function, as well as using the date input date function in.
5
00:00:23,250 --> 00:00:30,060
Just a quick reminder to you, if you were not concentrated and that's very important, that you will
6
00:00:30,060 --> 00:00:37,700
be concentrated and each the material every second of the course, because if you miss one thing, it's
7
00:00:38,340 --> 00:00:45,960
it will be very hard to, like, fill these gap and to proceed and move on with the more more advanced
8
00:00:45,960 --> 00:00:46,680
material.
9
00:00:47,160 --> 00:00:53,670
So what we have done previously is that we use the time definitions, truck, date, day, date.
10
00:00:54,570 --> 00:01:02,070
And we know that now every time that we are going to use the word date, it is just equivalent as we
11
00:01:02,400 --> 00:01:04,910
have been using previously structured date.
12
00:01:05,310 --> 00:01:07,320
So we created the structure.
13
00:01:07,440 --> 00:01:11,990
Then we wrote down the print date function.
14
00:01:12,000 --> 00:01:12,780
That's the name.
15
00:01:12,780 --> 00:01:19,350
That's the type receiving a date D.T. and printing out the year, the month and a date values.
16
00:01:19,740 --> 00:01:26,910
And also we have the second functionality responsible for all of the operations we've done here, using
17
00:01:26,910 --> 00:01:29,310
the second half in print F and so on.
18
00:01:29,460 --> 00:01:37,470
And the reason why the reason why we took and like, you know, you split it out the code of all of
19
00:01:37,470 --> 00:01:45,750
these part to these function to date and also all of these code to the print date is because we want
20
00:01:45,750 --> 00:01:53,220
to leave our main function as clean as possible and to separate the functions that are going to be like,
21
00:01:53,220 --> 00:01:56,640
you know, repetitive functions to different functions.
22
00:01:56,670 --> 00:02:02,210
So, for example, you know that you will use print date probably more than just once, OK?
23
00:02:02,370 --> 00:02:09,060
And probably more than just for one date variable as well as you're probably also going to create more
24
00:02:09,060 --> 00:02:14,130
than just one date variable in your program, in your code.
25
00:02:14,310 --> 00:02:21,000
So this will be a function that is responsible for everything instead of having everything in the main
26
00:02:21,000 --> 00:02:25,560
and just duplicate and duplicating the code and messing everything up.
27
00:02:25,590 --> 00:02:32,220
OK, so once it's clear why we've done it and make sure you watch the previous videos, because I'm
28
00:02:32,220 --> 00:02:39,270
not going step by step on these two functions, I'm going to proceed and to make some use in the main
29
00:02:39,270 --> 00:02:46,860
function that will take both are will take, will utilize and take advantage of these two functions
30
00:02:46,860 --> 00:02:50,220
that we just created the date and the print date.
31
00:02:51,000 --> 00:02:58,290
So first of all, let's create our new date, let's say date, graduation, graduation, date.
32
00:02:58,920 --> 00:03:03,240
And we just created a variable and it's not initialized.
33
00:03:03,240 --> 00:03:05,820
None of its fields are initialized.
34
00:03:05,820 --> 00:03:09,510
And one way to do so is to use graduate date.
35
00:03:09,630 --> 00:03:13,050
Graduation date equals to input date.
36
00:03:13,710 --> 00:03:19,500
And basically what will happen here is that once we reach this line, we will simply call this function
37
00:03:19,500 --> 00:03:20,160
in to date.
38
00:03:20,160 --> 00:03:27,570
And it is in charge of creating everything, four of these for the structure, reading the values from
39
00:03:27,570 --> 00:03:30,390
the user and returning the result.
40
00:03:30,750 --> 00:03:36,300
And once the result is returned, instead of using these complex print f, we will simply use print
41
00:03:36,570 --> 00:03:40,920
date and specify what we want to print the graduation date.
42
00:03:41,160 --> 00:03:42,830
And there you go.
43
00:03:43,320 --> 00:03:50,450
So what will happen now is that if we build and run it, we will see enter a date five, six and 2021
44
00:03:50,910 --> 00:03:51,720
and there you go.
45
00:03:51,720 --> 00:03:53,760
You have the year, the month and the day.
46
00:03:53,940 --> 00:03:57,120
Everything is working exactly as we expected.
47
00:03:57,480 --> 00:04:06,240
And if for some reason you also want I don't know, like like I don't know the date of today, for example,
48
00:04:06,240 --> 00:04:08,370
OK, the date today date.
49
00:04:08,880 --> 00:04:10,650
So you create two variables.
50
00:04:10,800 --> 00:04:13,440
OK, the first one is graduation day.
51
00:04:13,440 --> 00:04:14,580
The second one is today date.
52
00:04:14,760 --> 00:04:16,590
Instead of duplicating code.
53
00:04:16,740 --> 00:04:24,710
What do you simply do is today date today date equals to date once again, input, input, being put,
54
00:04:24,990 --> 00:04:26,040
input, date.
55
00:04:26,040 --> 00:04:28,830
And if you want to printed you simply print date.
56
00:04:29,250 --> 00:04:31,950
And you specify here that today date.
57
00:04:32,340 --> 00:04:33,420
There you go.
58
00:04:33,420 --> 00:04:39,600
See how clean the main function remains in how we utilize and take advantage of both of these functions
59
00:04:39,600 --> 00:04:45,170
that we've just created, simple as their guys, instead of putting everything like, you know, like
60
00:04:45,180 --> 00:04:49,470
putting all of these code for the graduation date here.
61
00:04:49,470 --> 00:04:55,050
And instead of putting everything for the today date here, we simply use this function as separate
62
00:04:55,050 --> 00:04:58,590
units and we work with them correctly.
63
00:04:59,190 --> 00:04:59,790
So I hope.
64
00:04:59,870 --> 00:05:00,570
That's clear.
65
00:05:00,750 --> 00:05:06,650
That's, I think, good enough for the basics of structures, understanding how to work with them,
66
00:05:06,920 --> 00:05:13,130
how to function, work with structures, accessing, reading, printing and so on.
67
00:05:13,910 --> 00:05:15,440
So thank you guys for watching.
68
00:05:15,470 --> 00:05:16,670
And let's move on.
6916
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.