Article View: comp.std.c
Article #3357Re: Is this a good Idea??
From: Thad Smith
Date: Sun, 08 Oct 1995 22:45
Date: Sun, 08 Oct 1995 22:45
42 lines
2644 bytes
2644 bytes
In article <454sem$1sk@ixnews6.ix.netcom.com>, miker3@ix.netcom.com (Mike Rubenstein) wrote: >jjwright@niflheim.rutgers.edu (John Wright) wrote: > >>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
Technical Details
Message-ID:
<459kaa$1vc@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<453cm0$fk5@niflheim.rutgers.edu> <454sem$1sk@ixnews6.ix.netcom.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: thads@csn.net (Thad Smith) Newsgroups: comp.std.c,comp.lang.c.moderated Subject: Re: Is this a good Idea?? Date: 8 Oct 1995 17:45:30 -0500 Organization: T3 Systems Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <459kaa$1vc@solutions.solon.com> References: <453cm0$fk5@niflheim.rutgers.edu> <454sem$1sk@ixnews6.ix.netcom.com> Reply-To: ThadSmith@acm.org NNTP-Posting-Host: solutions.solon.com