Article View: comp.std.c
Article #4194Re: Is this a good Idea??
From: Mike Rubenstein
Date: Sat, 07 Oct 1995 03:33
Date: Sat, 07 Oct 1995 03:33
35 lines
2183 bytes
2183 bytes
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. >What I want to know is if this is a bad idea for any reason. If the >person grabs the C code they need and compile it on their system, is >there any reason to believe they couldn't read the data file? >We are at a starting point now and want to preclude any problems now. 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 easiest solution is simply to store the data in character format, If that's not acceptable for performance reasons, define an interchange format that only uses character data and write programs to convert between that and the binary format. Such programs can be source portable between machines. Michael M Rubenstein
Technical Details
Message-ID:
<454sem$1sk@ixnews6.ix.netcom.com>Path:
arc1-ca.pugleaf.net!ix.netcom.com!netnewsReferences:
<453cm0$fk5@niflheim.rutgers.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!ix.netcom.com!netnews From: miker3@ix.netcom.com (Mike Rubenstein) Newsgroups: comp.std.c Subject: Re: Is this a good Idea?? Date: Sat, 07 Oct 1995 03:33:46 GMT Organization: Netcom Message-ID: <454sem$1sk@ixnews6.ix.netcom.com> References: <453cm0$fk5@niflheim.rutgers.edu> NNTP-Posting-Host: ix-dc15-05.ix.netcom.com X-NETCOM-Date: Fri Oct 06 8:33:42 PM PDT 1995 X-Newsreader: Forte Free Agent 1.0.82