when I write a number to binary file, it won't display. but in case of a character, it does. why? how would you check to see if the file containing character is binary?
It has all to do with how you interpret what is in the file. Everything in a file is binary, a character an integer etc.
When you do TYPE in the console on a file (or CAT or whatever OS u have) the contents of the file are interpreted as text by default because the programmer of TYPE decided to write it like that.
When you write a program to read out data from a file it is up to you to decide how to interpret the data what you read.
That is why you can only guess file contents and that is why often the extension of a file is used to give a hint on how the contents should be interpreted.
I think what you're really asking is whether you (personally) can interpret what's in the file.
As Anders alluded to, you can usually read a file as text regardless of what's in it - the characters, however, might make no sense.
Assuming you're writing software to perform this task, perhaps the following (high-level) algorithm will help:
Does this help?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With