Hi guys.
Welcome back in the election we have seen how to read the file content in 3D format and we are able
to read the file successfully and very able to see in the sequence.
Okay but now what we're gonna do is we're going to write the data into a fine.
Okay.
Which means like a user getting all the data.
It'll be easier enough.
Okay so let's get started.
Okay.
As usual like had mentioned me earlier assertion that is a different since I'm going to use some of
the inbuilt functions I have including this one is the main function of the program execution always
has one main function.
So now I have a character study with the variable of C hatch and is a five pointer and that is a file
pointer which we need to declare in the beginning of the program.
Then after that I'm just right opening this fight and Frank format in the Iliad tutorial what that is.
We just opened its final read format since we are going to write the data we have to open the file and
the right format.
So these two are a mandatory declaration and this opening the file.
Okay then as usual what I'm doing is once I open fine I'm just taking it as any knowledge if it is a
null outlet.
Okay I'm not able to open a fight which as I told you earlier when you open the file if the C program
is not able to open the file successfully then it will throw it at any null.
So that's why I'm putting a conditional here I'm just checking if this value of this file point or have
no value if it is null means it's not able to open the front and we'll print dismisses anybody else
in this program.
Okay.
So in case if it's successful like for example disabled or with the file then it's probably this message
will loop from there to the user file and successfully enter the sentence to save.
Finally an inbuilt function called get as which is used to read this string from the second sort from
the keyboard input.
Okay so whatever I'm capturing here with the help of f printer function I'm writing it in the file pointer
which means it will be writing in the text file which we opened in the right.
Okay so with this note in the safe print stuff will have three parameters.
I'll get the first one is the 5.0 the second one is the former specify essence is a string I mentioned
as as here and this is the value of the data so which we are going to feeding.
Okay so after that I'm just using this f close function I know to close this fight and zero signals
the normal definition.
Okay.
Again I'm repeating this the Category C hitch and after that is a file pointer which I'm going to delete
under at the end of this find when I'm opening this file and write more if the file is available I do
or what I did.
If if the file is not available to create in your files and I'm checking whether this file point has
any value for this number did not have a double defined and if it is not giving any null then it's failed
to give the message file open successfully enter the sentence to say that just having the file and with
the help of get us get a final function I'm I'm getting the data from the user under with the help of
a print function I'm saving.
I'm writing I'm writing all the content into this 5.0 which I'll be writing it on in the next flight.
Okay.
With that I'm just going closing that fine point now for that I'm just returning zero.
Okay so let's execute this program and see what happens.
I'm building this fine.
Okay.
So no there's no sign.
Okay no I'm just building and finding it okay.
File opened successfully and did it send us to see the fight.
So since there is no file it created the fight to see it go to the file just now.
So no I'm writing something like Welcome to my to.
Okay.
Welcome to my tutorial.
So we will do more testing.
Uh okay.
We let it be like this.
Louise
go this way.
Mm hmm.
You go to one more time.
File Open successfully enter the sentence just in the file.
So this message has been prompted.
No what we can do is handle.
How are you.
Okay so let's see what it is contained this statement has been captured here.
See.
Hello how are you so successfully getting up here.
But this note whatever it is written Oh I didn't get over it and I want all the data available earlier
it will be overwritten and just new content will be added next.
So you do not hold all data in the world data.
Okay so now what we can do this like we have a this goes there board to read more.
Right.
And we this because I would like more read more of what is being done.
We have just captured the content from a file existing file anyway stated in the second zone and in
the right mode we have fitted our content data into a fine guess and what we said successfully.
Okay.
What we have seen successfully.
So no one.
Okay.
As you know a situation where I don't want to delete all data.
So I want to upend it.
Okay.
And I think it's a more complete picture.
So for example I'm doing what I'm doing is I'm just changing this morning at 8:00.
So we are tested with art that we know.
So now what happens is when you put e up and more so what are your.
What are you keeping it up and on top of it.
This data will not be deleted.
Okay let's test this one
OK.
So I'm just closing this one saying it again building and run.
I and successfully.
Believe is
this thing.
The program using a more so I don't say it's done.
Let's see what happens.
See listing the program using a more OK so that all data was not deleted.
You just appended on top of the existing data.
So oh so this is how we can write the data or open the data using a C program by using file handling
functions.
Thanks a lot for watching this video.
I'll get you guys in the next session.
Bye for now.