Quote:
>>We are trying to create a dataset which will eventually be transferred
>>to many different users on many different machines (unix, mac, dos,
>>etc). We plan to create the dataset and a number of routines for
>>extracting data from the dataset into various software import formats.
>>The question is this, I am going to be programming in ANSI C. I want
>>to read and write the files in binary format. Every variable or
>>number that I write to the file is between 0 and 255 (one byte). I
>>plan to write all the variables (characters and integers) as
>>characters with a simple fprintf statement. We will then make the
>>datasets and the ANSI C routines available to others who will
>>retrieved them over the internet.
>You're asking for trouble. There is simply no standard format for
>data. Different machines will have different formats for arithmetic
>data. int will have different sizes, different byte orders, and if
>you range far enough in your hardware, different basic formats. Same
>for double. Even characters aren't safe if you're going to be using
>mainframes.
The fact that there is no defacto standard for stored binary data
doesn't prohibit the usefulness of the concept. There are several
binary graphic formats and file compression formats that are used on
multiple systems. What is required is that the data format be
explicitly specified, including length of data items, order of bytes,
representation of signed data, missing data, etc. The code can
be written accordingly, rather than simply giving giving a struct
declaration, for example, from which the data is written.
I have worked on portable code to use a scanf-type control string to
allow parsing of a variety of binary formats. Unfortunately, the work
was not completed and I don't have a current use for it.
To relate this to the topic of the C Standard, I understand there is/
will be a proposal to address external binary data formatting. I look
forward to seeing it.
Thad