All language subtitles for 4. Start with Files Steps and Syntax in C

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
hu Hungarian Download
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

Hi, guys, my name is Vlad is Alphatech.

And in this video, we are going to start working with files in our programming language.

So up to this point, we know some reasons as to why we should even start considering using files.

And these concept, let's say, of files can be implemented in many programming languages like C, C++,

Python and so on.

But here we are and the tutorial of the course of C programming language.

And we are going to learn how to work with these files in C, so guys get ready and let's go.

And first of all, what I want us to talk about is a couple of different operations that may be done

on files.

So we will talk about creating new files, writing new files, overwriting existing files, reading

from files and what is this operation of closing files even means and so much more.

OK, I think there was a lot of things we will talk about.

So to do different operations.

OK, let's start with talking about the actual things that interest us.

So to do different operations on files, the first thing that we need is to create or better, I say,

to declare a pointer of file type.

That would be the first step.

So similarly to the way we've created pointers of type int, for example, we use like this in Starp,

OK, which was like a pointer called P, which is a pointer to end or basically like double star, I

don't know, P two and so on and so forth.

In a same way, in a very similar way, we are going to create a pointer of a file type, OK, something

new but nothing to be afraid of.

OK, just a different type.

So just to give you some brief explanation, a file, OK, but we will create a pointer to a file type.

These file is actually a struct that, let's say was designed to be used for working with files.

OK, so it's really dedicated to working with files, as you probably already guessed by now.

And these type of struct and a pointer to this struct will help us to work with files, read from them,

write to them and so on and so forth.

OK, you can see that the file struct is actually being defined in this SDD iodized H.

And it is very similar to how you've defined and worked with different strokes, but basically it has

been already created in some other library and now it is just being.

Used in our program, so struct files struct, you've got the point.

And now let us start talking about the basics index for working with files, so first of all, we said

that we want to create a pointer, a pointer to a file.

So how it will look like so file specified file start and let's go F.P. file pointer.

So this step involves creating a pointer.

That its name is F.P., right, an abbreviation for file pointer that points that points point to a

file type.

All right.

And if it would like to take maybe a closer look at file, here is some strong.

OK, I will not go into all the details here.

OK, but there is much more thing we can talk about an hour or two, just about the files tracked and

what it contains, what information it has and so on and so forth.

So this will be like step number one.

OK, so let's classify it as step number one, creating a pointer that holds that points to a file type.

All right.

It will look like this.

OK, let me get it.

Come here.

Awesome.

So now let's fix this also.

Yeah, OK, so we've created these file and now we are going to see how we can open a file.

So basically just having a pointer is not enough.

OK, we need somehow to make this pointer to be associated with some file whether is going to read from

these file or we are going to write these file, but we need to specify that this pointer will be associated

with it.

So step number two usually is going to be opening, giving access to a file and how it's going to be

done.

OK, so we will specify that we will work with F.P., will hold the address that will be returned by

this function f open file open.

And here we will specify two things.

The first thing that we are going to specify, the first argument is going to be the file name.

OK, it's just going to be some string specifying the actual name of the file.

So if we want to read some file, we have to provide its exact name.

So that's about reading from a file from, let's say, some existing file will need we will need to

provide its exact name and if we would like to write to some file, then the string that we will use

here will provide the name of the file to be created.

OK, so if there is no file, we will need to specify the file name that we want to create.

So this will be the first argument that we will use here and we can classify it like this, OK?

Let me just right.

The the structure itself.

So it will be like ftf open and there will go like the file name.

And afterwards we are going to specify as the second argument, the type of the operation type of operation.

All right.

So that's basically the the signature.

And these type of operation is basically also a string that specifies what type of operation we want

to make with this file.

OK, so we said there will be like the file name and there will be the type of the operation on what

point is this even type of operation even means basically it's used to specify in what way are you expecting

your program to interact with a given file, whether it's going to be used for writing, reading or

basically even for a pending mode.

OK, so if you want to read from a file, specify the mode for reading.

If you want to write to a file, specify a mode for writing.

If you want to append something to an existing file, OK, to the end of the file, let's say, then

use the append mode.

Of course there are also additional modes, but I'm not going to discuss each and every one of them.

I'm just going to give you, let's say, just the three most basic that will make you ready to use files.

And the first one, the first, let's say here are types, types of operation.

OK, so the first one is called W OK, and this is an abbreviation for writing mode.

OK, that's a string.

Right.

We do recall.

What is the difference between strings and Charas.

Right.

So by using this way, as far as the second argument, we are using a string in these double quotation

marks and W is specified for writing, OK, this string is used to indicate the type of the operation

for the file we will be working with.

He's going to be writing, so we will open a file for writing.

OK.

The second type of operation is, as you've probably guessed by now, are for reading.

OK, so this drawing indicates that the type of the operation for the file will be reading.

We will be able to read the contents of the provided file.

OK, if we use these type of

operation and the last one, last but not least, OK, there are also additional ones that you can explore

on your own, or basically I will cover up some of them in the future.

But basically for now it's it's pretty much you have to understand writing, reading and spending.

OK, so A will go for a landing mode and the string tells us that we can append information to the end

of the file.

OK, so if the file exists, what will happen to the end?

If it does not exist, then probably a new file will be created.

OK, and then we will be able to use it.

So let's use some, I don't know, some example in this video or let's say let's give it in the next

one.

Just explain all the steps right here.

And afterward, I will show you some example of real string for a file name and usage of some type operation

with some nice example.

So let's make it like to do complete.

And what also I want to tell you is that these f open function that is being used is included in our.

In our standard input output header file.

OK, so this is a function somebody has written.

OK, you can see it's each type in what it does, it returns a pointer to file.

That's why we can assign it to FP and also come here.

And also you see what it expects to receive.

It expects to receive a file name and it expects to receive a mode, which is exactly just as I've shown

you right now.

So f open returns a pointer to a type file if the operation of opening the file has been completed successfully.

Also, something that you need to understand is that not every time that you will try to open up a file,

this will be done successfully.

So if the operation of opening a file, whether it's for writing, reading and or appending he's going

to fail, then these function f open is going to return null.

If something went wrong and the operation of opening could not be accomplished successfully, then F

Open is going to return now.

And then you will have to like to check in to make sure if let's say FP does not equal to now, OK,

then it means that the operation of opening the file was successful and you can start working with the

file whether it's right into the file, read from the file or a band and so on.

All right.

So.

Mm hmm.

So this is used to make sure to make sure that the open operation was successful.

And finally, finally, finally, once we are done working with our file, either it was for reading,

writing.

And so, one, we want to specify that we are a done working with these file.

And as we've said, there are plenty of reasons to specify that we didn't say.

Yeah, but for example, if you're working with a file, you're writing to it and you would like to

basically to start reading from it from another process or another function or another, I don't know,

some program.

So it may be kind of hard went and it's a place for bugs when there is a stream of input writing to

the file and there is a stream from another process reading from the file and basically what happens

first or basically if someone else is writing this file.

So this may be kind of problematic.

So.

For this, you would like to specify that whenever you are done working with a single file, just close

it, close this stream, these direction of working with the file, specify that you want to start work

to stop working with the file from this program.

OK, so f close file, close FBI file pointer.

Specify that for these programs you've written all the code relevant to working with the file.

So some code for working with a file with the file and once you are done working with the file, simply

specify f close F.P..

All right.

Awesome, so just to go over the main steps required first step, creating a pointer of type of pointer

to file, then opening your file based on the file name and the type of operation that you want to use.

Step three, let's classify it like as step three.

Step three, make sure the opening was successful.

Make sure the situation successful.

Yeah, that's right.

And if I'm not wrong, step for step for work with the file, work with the file, reading, writing

and so on.

And final step.

Don't forget this one step number five.

Step number five, close the file.

It doesn't mean like to close or delayed the filing, just means that stop this connection and maybe

we will see also where it's.

Actual problems, OK, like real problems may occur if you do not do so.

So, yeah, I think there will be examples that I'm planning to show you this problem.

But for now, you stopped working with the file.

For example, you created a file.

You wrote all the information to there.

So stop it by using the F close.

So just cut the link between your program and the file.

So these file will be accessible and will allow working from different places.

Okay.

Oh, so basically nothing complicated.

Guys, follow these steps and the next videos we are going to see some practical examples that will

show you that files are actually kind of easy, fun and very useful.

So my name is Vlad.

This is Alphatech.

Thank you so much for watching.

And we will meet we'll see each other in the next videos by.

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