The term "conversion from plaintext to binary" is unclear. fread() does not convert binary to plaintext.
The main difference is, that "text"-Files use ASCII encoding, e.g.
These are 16 characters to store PI. Parsing it and converting it to a double requires 15 multiplications by 10, an expensive power operation might be needed also for strings like '3.14e-15'.
In opposite to this, storing pi in binary format uses 8 bytes:
This looks strange, but it is a stream of these bytes: [24, 45, 68, 84, 251, 33, 9, 64]. This can be copied directly to the memory and no further arithmetic is needed.
Binary files can have different types. E.g. the above byte sequence [24, 45, 68, 84, 251, 33, 9, 64] can be one double value, but it could be 2 single values also: [3.370281e+012, 2.142699], because a single uses 4 bytes per element. Therefore the software has to know the type of each variable stored in a binary file.
I suggest to copy a JPEG file, which is an example of a binary format. Then change the extension to ".txt" and open the file in the editor. This does not convert anything, but the byte sequences store in the file are interpreted as characters now, while the same contents is handled differently, when the computer assumes that this is a jpeg encoded picture. Finally you can change the extension to ".mp3", another example of a binary format. Of course your player will fail, because it will have a malformed contents.
Does the difference between "binary" and "text" become more clear now?
Best Answer