Hi Patricia! Thanks for the some method! I had never seen it before!. I'll definitely change it.
For your other question, I'll try to reply to the best of my knowledge.
Any file doesn't matter if it's an image, binary, audio, etc. contains data which ultimately gets processed by your CPU and then gets displayed correspondingly. Let's say you open an image with a text editor, you'll see a sequence of squiggly characters that make no sense. Yet, in the beginning, the file contains a signature that tells you what kind of file it was when it got created.
I don't really know why it is like that but I guess that the developers made it that way for software to be able to recognize which kind of files they are and how to read them.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Just a small question, why do the four first bytes tell us the real type of the file?
Also, by changing your validation
for
cycle to asome
, it looks cleaner and you can even spare yourself some iterations:Hi Patricia! Thanks for the
some
method! I had never seen it before!. I'll definitely change it.For your other question, I'll try to reply to the best of my knowledge.
Any file doesn't matter if it's an image, binary, audio, etc. contains data which ultimately gets processed by your CPU and then gets displayed correspondingly. Let's say you open an image with a text editor, you'll see a sequence of squiggly characters that make no sense. Yet, in the beginning, the file contains a signature that tells you what kind of file it was when it got created.
I don't really know why it is like that but I guess that the developers made it that way for software to be able to recognize which kind of files they are and how to read them.