Hi everyone.
So in this video we want to understand the difference between the text file and the binary files so
the definition is very simple text file that those file that are human literally.
Well so basically human can easily read text files but binary files are not very human friendly so they
are basically machine readable now let's see how the data will be stored in text and the binary file.
So for example in your program if you're doing something like this in Texas 23.
So if you want to store the data in binary files so what will happen.
So this 23.
So what is a binary representation of twenty.
So this is 1 0 1 1 1.
And we know basically integer is of 4 bytes so 4 bytes means 32 bits.
So basically in binary what will happen you will have to do two bits so these are two little bits first
eight bits are all zeros the next eight bits are also all zeros the next eight bits are also all zeros.
So then here you have 1 0 1 1 1 and then there are three zeros.
So basically this will be stored in your binary file.
So this is 0 0 0 0.
You can write all the zeros.
And finally you will have 1 0 1 1 1.
Okay.
So you're buying verifiable stored data in this format.
Now let's see how this string degree will be stored in our text file.
So what will happen first of all this too will be converted into into its archive and do so ask any
value of two is actually 50.
Similarly t will be converted into its ask value and ask the value of trees 51 so missing really my
mother to ask a value of 0 is 49 and similarly it will go on so that I ask a value of when will be fifty
and it will go on like this so what will happen.
This tool is going to be converted in goods ask a character called.
So this value is actually 50.
So what will happen.
So this 50 is going to be converted into its binary form and its binary farmers 1 1 0 0 1 0.
And similarly the binary form of 51 is 1 1 0 0 1 1 and basically ask take only one bit so you take only
one byte so how many boots are there one two three four five and six so two zeros will be appended here
and twos the list will be appended here then in the text format what will happen.
I was told it in this format.
1 0 0 1 1 0 0 1 0.
So this thing and now I restored this thing.
So this is actually 0 0 then 1 1 0 0 1 1.
So this is how I was told the data in the text file and this is how I will store the data in our binary
file.
Now I told you that the text files are human readable but I don't think this is your money really well
so why I told you that.
Takes to until you manage really well.
So let's discuss.
So what will happen you will open the text file into your notepad.
Now what nobody will do so it will pick the first 8 bits it will pick the first 8 bits and it will convert
into its ask value.
So this is going to lose actually Fifty and fifty is corresponding to three of these corresponding to
two.
So instead of this the notepad will print two.
Similarly it will pick the next eight bits.
Again it will find out the ask value which is fifty one then the character corresponding 251 is three
so three will get printed.
If you will open the file in notepad but this is binary.
So if you will open the binary filing notepad.
So what will happen.
It will pick the first 8 bits.
So the first 8 bits are actually 0 also the first eight which set actually 0.
So it will happen.
The correct corresponding to ask I lose you know will get printed.
So what is the character corresponding to the sky values 0.
So ask a value 0 and the character corresponding to asking will lose zero sum will be a very meaningful
character.
Very strange Celtic Bill question mark or it can be anything.
So we know that there will be some asking will look corresponding.
I think it is nil.
Yes I remember it isn't an so this isn't that.
So what will happen now it will get printed again the next eight which are evil.
So again none will get printed.
Again the next asking value of zero.
So again none value will be rendered.
And this is actually so what is this number.
So this number was twenty three.
So the asking value corresponding to quantity will get printed and it will be a very strong symbol.
So let's say this question mark.
It will be a very meaningful symbol.
So finally what will we had output.
This will be it output to fill open the file if you open the binary file in notepad so and we know this
is very meaningful to us.
So this is under meaningful unintelligible
so this thing is unintelligible.
So that's why I told you that the text files are actually humility devil and the binary files are basically
machine readable.
So how can we read and write it out into the text file so we can use these operators so we can use this
operator to read and write it into a text file.
Now if you want to read and write data in two binary file then basically in C++ you have a mode and
this mode is actually a US I don't remember exactly.
So I think it is a US binary.
So this is the mode if you want to take if you want to read and write data to a binary file and there
are also functions.
So the functions are doing the function to read the data.
And similarly you have a function right so this read function is actually in the class ice cream.
I think it is input stream.
And similarly the right function is present in the class output stream.
Now let's discuss which one is faster.
So text or binary so actually binary our faster binary files are faster and the text files a slower
via this slower it is slower because of the conclusion.
So this is how we are studying the data and this is how we are displaying the data.
So basically there is some calculation involved and you do the calculation it becomes slower and it
is faster now let us discuss which will take more space.
So basically this is going to take more space why more space.
And this is going to take less space so let us consider one example so suppose you want to store this
number.
So you have something like an X equals let's say a bigger number.
So let's say 4 7 3 2 5 and 6.
Now if you want to store this number in binary what will happen.
So again binary integer is basically 32 bits or we can say for bytes.
So if you want to store this number in binary it will take four bytes simple.
So just like here.
It is going to take four bytes or you can set twenty two bits.
Now let's see how much space will be taken.
If I want to store this number in the text file.
So again what will happen.
Each digit will be converted to ask value and we know the square value is basically one byte you can
see.
So this is one byte so this is one byte then two byte then three then four and five and six.
So if you want to store this number in the text format in the text format you will take six bytes so
each digit will take one byte so you will take six bytes here and you are taking only four bytes here.
So it's a binary files are taking less space in binary files are faster now the only advantage that
text file have is basically the added human leader table.
So this is the only advantage the text file not having that they are human leader table and binary files
are basically machine readable rest everything binary files will win.
So binary files are Foster and binary files are taking less space and I want this text file has is basically
we can understand them and we can not understand designed to be filed.
So that is all about the text and the binary file.
So I will see you in the next video by.