go to previous page   go to home page   go to next page        

Answer:

Not in general.

Common Problems with Binary Files

If the data is expected to fall into a known range of values, then a program can check for valid input values. Sometimes other things are known about the data that can be used to check it. But otherwise, there is usually no way to check. Bytes written in one format can usually be mistakenly read in with another format. You have to be sure that the data file and the program match.

This is a common problem in programming. Some files are many years old and were created with poorly documented programs that ran on now obsolete computers. Figuring out how to read them is often a case of detective work.

Often a file will have a header that describes its data. This is common for image files, for example. A program that reads the file checks the header to verify that the file is what is expected. It is common for the header to include additional information such as the date of its creation and the version number of the program that created it.

Of course, now you need to know the format of the header, and that can be another problem. Many file headers start with a several byte code that indicate what format the remaining bytes of the file follow. For example, GIF image files start with the six ASCII characters GIF89a.

QUESTION 5:

(Thought question: ) Could a binary file other than a GIF image start with the six ASCII characters GIF89a ?