FORTRAN type I/O in C - Help!

GRIFFIN,JEFFREY A griffin at prism.gatech.EDU
Thu Jun 27 05:38:21 AEST 1991


HELP! from a C guru urgently needed and appreciated.

I am looking for suggestions for reading a data file of which two 
records are listed below.  Each record consists of 512 characters 
plus a new-line.  There is an initial byte count of 0133 then 32 
integer values, another byte count of 0133 and 32 integers, the
last byte count of 0133 and the last 32 integers.  The remainder of
the record is padded with the '^' character.  The read would
certainly be more trivial if the last integer in each group was 
followed by a space before the next byte count.  In FORTRAN I would
read this as 3(I5, 32(I4)).  I would like to read each record into
a buffer string and then process the record.  In this way I can keep
better track of where I am in the file and track any possible
alignment errors when trying to read the file.

(1) What would be the best way to handle this?

(2) Has anyone written any I/O routines that are similar to doing
    formatted reads in FORTRAN?  For example a read command that
    supports the grouping of numbers i.e. 32%5d, etc.



0133   45  46  46  44  45  46  46  46  46  46  47  46  44  45  45
  45  47  46  45  46  46  45  45  46  46  47  46  46  46  46  46  
460133   46  46  46  46  46  47  47  47  47  47  47  46  46  46  46  
46  46  46  46  46  46  46  46  46  46  46  47  46  47  48  47  
470133   46  45  45  47  47  47  47  47  47  47  47  47  46  46  48  
47  47  47  46  45  47  47  46  47  47  46  46  47  46  46  46  
45^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0133   46  47  47  47  47  46  46  47  47  47  47  47  48  47  47  
46  46  46  47  47  46  47  47  45  46  46  46  46  46  46  47  
460133   46  48  47  47  47  46  47  48  46  47  46  45  47  47  47  
47  47  47  47  47  47  47  47  47  47  47  47  46  46  46  45  
470133   48  48  48  46  47  47  46  47  47  47  47  47  46  47  47  
46  47  47  46  47  47  45  46  47  47  47  47  46  47  47  45  
47^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- 
Griffin, Jeffrey A.
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!griffin
Internet: griffin at prism.gatech.edu



More information about the Comp.lang.c mailing list