Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,630 --> 00:00:01,400
Welcome back.
2
00:00:02,300 --> 00:00:08,990
If we want to write different things through the screen, then something that we've already learned
3
00:00:09,200 --> 00:00:16,940
is that we know that we could use the printed function with various different placeholders to put different
4
00:00:16,940 --> 00:00:18,400
information to the screen.
5
00:00:19,130 --> 00:00:25,100
For example, if we wanted to print integers through the screen, we could have used the percentage
6
00:00:25,100 --> 00:00:32,360
D and if we wanted to print, I don't know, some floating point numbers, we could have used percentage
7
00:00:32,360 --> 00:00:35,240
F or percentage L.F. for doubles.
8
00:00:36,250 --> 00:00:44,590
We could easily work with different types of variables, and that's what pretty much I want I want you
9
00:00:44,590 --> 00:00:47,710
to be familiar with when working with files.
10
00:00:47,770 --> 00:00:48,340
All right.
11
00:00:48,940 --> 00:00:55,800
So basically saying so far we've seen the functions that work only with characters, right?
12
00:00:55,810 --> 00:00:58,980
These F get C and F Bootsie.
13
00:00:59,650 --> 00:01:04,270
And now what I would like us to do is simply to extend these information.
14
00:01:05,080 --> 00:01:07,110
So the question goes as follows.
15
00:01:07,570 --> 00:01:12,520
What if we wanted to write the things we print on the screen to some file?
16
00:01:13,120 --> 00:01:15,930
OK, just like we've done it with the printer function.
17
00:01:16,750 --> 00:01:20,110
Now we are going to see some more general example.
18
00:01:20,270 --> 00:01:26,050
OK, this one that I created for you, which will be done using the F print F function.
19
00:01:26,650 --> 00:01:29,760
So how the F printer function looks like.
20
00:01:30,820 --> 00:01:31,620
There you go.
21
00:01:31,660 --> 00:01:36,070
Here is the signature F print f it gets a pointer to a file.
22
00:01:36,220 --> 00:01:37,740
We already know what it is.
23
00:01:38,110 --> 00:01:44,410
It gets some placeholders and associated parameters with this placeholders.
24
00:01:45,100 --> 00:01:53,500
So for example, let me show you for example, so f print F F, B percentage D and num, which is of
25
00:01:53,500 --> 00:02:02,500
type Int and now one, we will run it, we will try to save to write this information into my first
26
00:02:02,500 --> 00:02:03,970
file 3.0.
27
00:02:04,750 --> 00:02:09,160
So let's run this program and basically see what it will give us.
28
00:02:09,730 --> 00:02:11,260
So where is it.
29
00:02:11,260 --> 00:02:12,160
Where is it.
30
00:02:12,640 --> 00:02:13,360
Where is it.
31
00:02:13,390 --> 00:02:13,810
Come on.
32
00:02:13,810 --> 00:02:14,410
Come on, come on.
33
00:02:14,440 --> 00:02:14,980
Here it is.
34
00:02:15,430 --> 00:02:19,540
So my file number three and there you go.
35
00:02:19,950 --> 00:02:21,300
Five hundred and twelve.
36
00:02:22,540 --> 00:02:24,460
So what does it teaches?
37
00:02:24,790 --> 00:02:31,270
It teaches us that it can place different formations, different information in various formats, let's
38
00:02:31,270 --> 00:02:36,730
say percentage and percentage d here will place like num multiplied by num.
39
00:02:37,240 --> 00:02:39,570
OK, let's make num a little bit smaller.
40
00:02:39,610 --> 00:02:40,980
Let's make it fif.
41
00:02:41,680 --> 00:02:44,330
Let's see what we will receive now.
42
00:02:45,040 --> 00:02:46,390
So there you go.
43
00:02:46,420 --> 00:02:50,670
My first file, three and 525 in the space between them.
44
00:02:51,370 --> 00:02:52,360
Pretty awesome, right.
45
00:02:52,840 --> 00:02:59,890
Very simple usage, just like we've used previously, just like we've used the printed function to display
46
00:02:59,890 --> 00:03:07,870
different information on the console application, just that now we specify where we want to redirect
47
00:03:08,230 --> 00:03:13,720
the flow of information and it will be to F.P., which is a pointer to a file.
48
00:03:14,880 --> 00:03:21,480
Also, one thing that I want to mention before we will finish up is that, of course, you can use higher
49
00:03:21,480 --> 00:03:23,610
percentage F, right?
50
00:03:23,610 --> 00:03:29,720
If you have, I don't know, float number two equals to nine point seven.
51
00:03:29,730 --> 00:03:30,110
I don't know.
52
00:03:30,120 --> 00:03:30,750
And so on.
53
00:03:31,030 --> 00:03:32,790
Miskelly, there is no problem with that.
54
00:03:32,790 --> 00:03:33,090
Right.
55
00:03:33,300 --> 00:03:38,640
Let's run it and see what happens just to make sure that everything is working OK.
56
00:03:39,330 --> 00:03:40,140
Oh, come here.
57
00:03:40,140 --> 00:03:40,740
Come here.
58
00:03:40,740 --> 00:03:41,160
Come on.
59
00:03:41,160 --> 00:03:41,610
Come on.
60
00:03:41,650 --> 00:03:43,020
OK, nothing is working.
61
00:03:43,020 --> 00:03:44,850
OK, so there you go.
62
00:03:44,850 --> 00:03:45,760
There is a problem.
63
00:03:45,780 --> 00:03:46,670
What is the problem?
64
00:03:47,160 --> 00:03:50,700
The problem is that we do not use here the proper values.
65
00:03:50,720 --> 00:03:54,780
So let's use here instead of NAMS that are integers.
66
00:03:54,780 --> 00:04:01,640
Let's use number two, which is of a floating point type to have everything associated with one another.
67
00:04:01,650 --> 00:04:03,350
So yeah.
68
00:04:03,750 --> 00:04:04,560
So there you go.
69
00:04:04,560 --> 00:04:06,900
Five and nine point seven.
70
00:04:07,740 --> 00:04:08,340
Awesome.
71
00:04:09,030 --> 00:04:12,690
And last note about the F print F function.
72
00:04:12,690 --> 00:04:14,340
Is that also.
73
00:04:14,340 --> 00:04:22,890
No, for now it's not so important, but maybe in more advanced exercises we'll use it the f print function.
74
00:04:22,890 --> 00:04:25,680
It also returns something OK.
75
00:04:26,370 --> 00:04:27,960
It also returns something.
76
00:04:27,960 --> 00:04:34,050
What does it return is the number of bytes it has successfully written.
77
00:04:34,500 --> 00:04:41,520
OK, so just know that f print f function returns the number of bytes it has successfully written and
78
00:04:42,060 --> 00:04:46,200
maybe even in these course I will show you some usages of this information.
79
00:04:47,080 --> 00:04:47,640
Awesome.
80
00:04:48,890 --> 00:04:56,810
And instead of dividing it into two separate videos, I decided also to include here the FS ganef and
81
00:04:56,810 --> 00:04:59,790
it works in a very similar way, OK?
82
00:04:59,900 --> 00:05:08,460
It reads information from the user, from the user, from a file and stores it inside different variables.
83
00:05:08,870 --> 00:05:11,630
So, for example, that's just for simplicity.
84
00:05:11,660 --> 00:05:13,580
OK, let's take this file.
85
00:05:13,580 --> 00:05:14,810
My first file three.
86
00:05:15,230 --> 00:05:19,790
Let's leave here, I don't know, one five one two that we had previously.
87
00:05:19,790 --> 00:05:21,320
Let's save it, close it.
88
00:05:21,320 --> 00:05:22,370
Close this one, two.
89
00:05:22,910 --> 00:05:25,280
And now let's modify this program a little bit.
90
00:05:25,880 --> 00:05:28,700
Let's go like reading mode, OK?
91
00:05:28,760 --> 00:05:31,430
And let's create this enum.
92
00:05:32,730 --> 00:05:41,020
Ain't no come on in now and we will read from these file.
93
00:05:41,070 --> 00:05:42,220
What will we read?
94
00:05:42,450 --> 00:05:50,080
We will read one placeholder percentage and where instead of print F, we will use F. Scott F..
95
00:05:50,580 --> 00:05:52,770
OK, so these function works very similar.
96
00:05:53,050 --> 00:05:57,730
It works like the F print F with the PHP pointer.
97
00:05:57,750 --> 00:05:59,820
In this case, some placeholders.
98
00:06:00,120 --> 00:06:02,840
And where should we store this information.
99
00:06:03,120 --> 00:06:05,130
So now it says that at all.
100
00:06:05,160 --> 00:06:06,140
OK, no problem.
101
00:06:06,450 --> 00:06:12,570
Let's use here instead of Naameh we should use percentage now write the address of NUM.
102
00:06:13,590 --> 00:06:18,720
So let's basically go like this and build and run it and let's see what happens.
103
00:06:19,410 --> 00:06:24,480
So basically nothing will happen because we need to show that we have got something.
104
00:06:24,480 --> 00:06:33,990
So let's print num from file equals to percentage there and we'll see if we've managed inside of these
105
00:06:33,990 --> 00:06:40,920
program from this program to get the value inside of a file called my first file three.
106
00:06:40,920 --> 00:06:41,850
That's sixty.
107
00:06:42,060 --> 00:06:46,520
And store this value as an integer into variable num.
108
00:06:46,560 --> 00:06:50,160
That's what all that's what we will see in line 24.
109
00:06:51,140 --> 00:06:52,340
Let's run it.
110
00:06:52,370 --> 00:06:53,040
Come on.
111
00:06:53,450 --> 00:06:59,200
So there you go, numb from file equal to one 12 to 512.
112
00:07:00,830 --> 00:07:04,760
So, yeah, this is this function, the second half.
113
00:07:05,360 --> 00:07:12,950
And what I want to finish here is that you will understand also that.
114
00:07:14,190 --> 00:07:22,020
The fiscal cliff and previously we had like f print F functions that we can also modify them, right?
115
00:07:22,050 --> 00:07:25,710
We have like percentage D and we have like these.
116
00:07:25,710 --> 00:07:31,950
Knowm So the F print F redirects this information into.
117
00:07:33,080 --> 00:07:37,220
The file, right, pointed by F.P., but we could also do so.
118
00:07:38,210 --> 00:07:43,790
By using what what's the index is very similar, there is the print syntax, right?
119
00:07:43,820 --> 00:07:46,670
So print F percentage D and here specify num.
120
00:07:47,570 --> 00:07:51,650
What will happen in this case will print the value of Naoum to the screen.
121
00:07:52,880 --> 00:08:00,860
So here we will print it to the file and I want basically to put it in the console application.
122
00:08:00,890 --> 00:08:04,700
So instead of F.P., what can we use.
123
00:08:05,240 --> 00:08:06,380
Standard output.
124
00:08:07,160 --> 00:08:08,600
Usted out.
125
00:08:09,800 --> 00:08:19,250
Is it clear and the same goes for scaff, so instead of using Caniff, right, and putting it inside
126
00:08:19,280 --> 00:08:23,150
numb, we can simply use it like this, Esterina.
127
00:08:25,110 --> 00:08:27,840
Just getting the different.
128
00:08:29,430 --> 00:08:33,490
Pointers stand there, are they input stand there with output and there you go.
129
00:08:33,510 --> 00:08:37,220
Basically, it works the same as the printer and the scanner.
130
00:08:38,340 --> 00:08:41,010
So very important, guys, for you to know that.
131
00:08:41,460 --> 00:08:46,350
And yeah, so that's about it for this video.
132
00:08:46,350 --> 00:08:53,910
And in the next last two functions for now that I'm going to discuss, we are going to talk about strings
133
00:08:54,270 --> 00:08:59,830
and what functions, maybe more useful, at least a little bit more.
134
00:08:59,970 --> 00:09:00,570
I don't know.
135
00:09:00,930 --> 00:09:06,470
Some have their advantages, while others have their disadvantages and so on.
136
00:09:07,530 --> 00:09:13,380
So we will see how we can work with strings, with two additional functions that will be called F puts
137
00:09:13,380 --> 00:09:14,760
and F Gettis.
138
00:09:15,180 --> 00:09:17,220
So thank you guys for watching.
139
00:09:17,250 --> 00:09:18,200
My name is Vlad.
140
00:09:18,330 --> 00:09:20,640
I hope you like this course and these videos.
141
00:09:20,880 --> 00:09:22,790
Let me know what you think of it so far.
142
00:09:22,890 --> 00:09:24,540
It's really important for me.
143
00:09:24,750 --> 00:09:34,920
It gives me a lot of feedback and where I can improve May and also where I have done things right and
144
00:09:34,920 --> 00:09:37,070
explaining to you in the best way I can.
145
00:09:37,380 --> 00:09:38,970
So thank you so much for watching.
146
00:09:39,130 --> 00:09:41,430
I'll see you in the next videos by.
12781
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.