All language subtitles for 11. fgets - function

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

All right, so in this video, we are going to talk about the F Gettis function and basically this is

another function for working with strings.

OK, so similarly to the pair that we've worked with in the previous video called the protest function

and the F protest function, we just explained them.

Right now we are going to talk about and show you some similarity between the GETAS function and and

the F getas.

So probably you remember the Gethers function that we worked with in the strings section to get s function.

And these function basically was an abbreviation for get string.

So basically what they get this function is simply reading or better say, getting a string from the

user, from the console application write.

Simply reading a string from the console and storing it in some variable so we could use it in our program

in the F, this function is actually very similar to Gettis.

It also gets a string, but that doesn't necessarily have to be from the console, but rather the get

function can read a string from a file file, get string.

That's the reason why it's called F gets simply get a string from a file.

Are we clear so far?

And now let's talk about the Afghanis syntax so the Afghan press expects to get as its first argument,

the string name.

It is the actual string where we are going to place the string from the file we are about to read in

the second argument.

We should specify what is the maximum size of the string we are going to read from the file.

So basically, it's just kind of a limiter to the number of characters we are going to read.

We don't want to read more than we can actually store inside different variables.

Right.

We have specific size for this.

And lastly, since we are talking about getting string's from a file, we should also specify from what

file we are going to get these strings.

So we should specify here probably the FP, right, which is a file pointer that we created to point

to our file, basically using the F open function.

Awesome.

So let's talk about how it works in practice.

In this example, I created an array of characters, my string of size, I created some count variable

that will assist us in printing some nice messages through the screen to demonstrate how the process

works.

And here we have F.P. a pointer to file FTF open.

We are opening some file for reading.

Let me show you this file.

Here it is.

This is The File.

Hey man, this is lot from Alphatech.

Do you love the course so far?

That's it.

And then we ask you, F.P. does not equal to now, meaning the file was successfully opened.

Let's do the following thing.

Let's use the F getters function as part of some while loop and on every iteration.

What we are going to do is basically to read ten characters from FP where FP points to and store them

inside my string.

Just remember that the last three, the last character should.

B, basically also for the backslidden zero at the end of the string, you do remember remember that,

right?

So let's run this program and see what happens.

So click on the local Windows debugger law, where is the file itself?

OK, here is the file and here is the result.

And I want us to make a little comparison.

So string number one, Red Hamen, OK, we can see that this line is less than 10 characters, so there

is no problem.

And also, we can see that we have here a backslash and printing a new line.

OK, good.

So actually, if we take a closer look, we will see that Hamen ends with the backslash and with a new

line right here.

And if we read it, we can see that there was a backslash in right here and also there was additional

backslash in right here.

So what's going on?

What is happening here?

OK, we can see that for the second time in our iteration, we read three numbers to read.

This is V, so it was like four characters, five, six, seven, eight, nine.

And the tenth character was basically for what?

For the backslash zero.

So this was like nine characters plus the Bixler zero STORIN Inside my string.

OK, awesome.

And here we see that we have like one, two, three, four, five, six, seven, eight.

And that's it.

So what's going on here is another one.

Basically here was probably also the space and after that, the backslash zero.

But lastly, one thing that I want you to understand is that the F Geddis function is used a little

bit differently than the Gettis in terms of that.

First of all, you read a string from the file until it reaches the first backslash m so we didn't continue

here to read like any parts of the second line, although we had like seven characters, including the

backslash and its eight characters.

We didn't read the T, for example.

So the F Gettis function reads a string from a file until it reaches the first backslash M and if there

is a backslash in character then it keeps it and just adds a backslash zero to the end.

OK, so basically just keeping the backslash in and adding the backslash zero to the end of the string

without making any replacements or how also the various function works.

It reads until we reach some limit specified hearing this argument.

OK, so whether we read, until we reach some backslash end or the total number of characters, including

the backslash zero, that should be also specified.

And if both of the specified conditions not deal the backslash then and not till these limiter are not

satisfied, then the Afghan dysfunction will simply read the whole string up until the end of the file.

And that's opposed to the get us function.

Basically, the GETAS function did replace different backslash and with a backslash zeros here we simply

add a zero to the end of the backslash.

And in case that we have this type of rating, so finally the F get us function returns.

Now if the operation of the reading was not successful, so there may be also times that.

The operation of reading will return now when the operation was not successful and in this case, maybe

the wire will not iterate anymore and it will indicate that something went wrong.

And also, that's a good practice for you to catch kind of catch these kind of errors.

So finally, to summarize both Buddhist's and get us and their Associated Press f protest and F Getas

is just basically adding these prefix for working with files and specifying a little bit different functionality

now for different cases.

But the main principle is the same for working with strings and files and basically putting strings

to a file, getting string from a file based on some rules that I've just specified.

So you can also write down these rules, make some notes.

And also a very important part is that you will practice on your own because only like that you will

understand and you will have different questions that can be answered.

And like this, you will improve and become a better programmer.

So before we move on, I just want to let you know, guys, that now you are the new totally new level

because you now know an additional important function for working not only with the council, but also,

you know, how to work with files.

OK, you know of various.

Six functions you've been introduced in the last few videos, you know how to work with files, working

with characters, working with different placeholders and files, working with strings and so on and

so forth.

So I think you can see how it will become handy.

And if not, we are going also probably in the next video to see additional examples and exercises.

So, yeah, thank you guys for watching.

Keep on practicing.

I will see you in the next videos.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.