Article View: comp.std.c
Article #3797Re: Help Needed...openiong/closing files...
From: William Wendling
Date: Mon, 21 Aug 1995 04:12
Date: Mon, 21 Aug 1995 04:12
35 lines
1786 bytes
1786 bytes
Mike Chilcott (mikechil@cris.com) wrote:
} I am new at programming, and have a little problem.
} I have a huge file (over 90+meg). It is broken down into
} records of 923 characters each. Each record consists of
} 30+ fields of varying size lengths.
} I want to open the file, read a record and assign each
} field a variable name. I then want to open an output file,
} and write certain fields to it.
} I have been told to try and use STRUCTS, but am
} having problems, understanding and implementing.
} Any help is appreciated....
C is not the language of choice in writing record handling applications.
COBOL is very good at that. However, you can open the record by:
FILE fo;
fo=fopen("file", "rt");
if it is a text file. If not, replace the rt by rb.
Then read each record in using an fgets function. (It is in the
standard library and should be in any of the docs.) This function
reads until a new-line char is encountered and then returns that
line with a trailing '\0'.
I suppose that you could have this being read into a structure of
some sort.
--
Bill Wendling | GM/CS/S d@ H- s-: g+++ p? au+ a- w+ v->! C+++(++++)
wendling@uis.edu | U+>++++ P+ L++>+++ !3 E N+ K--- W--- M-- !V
Boom Shanka! | po--- Y++ t+++ 5- jx R+>++ G? tv+ b++>+++ D
| B+++ e+++(*) u*(++) h!(*) f+ !r(*) !n y?
Technical Details
Message-ID:
<41912t$l70@eagle.uis.edu>Path:
arc1-ca.pugleaf.net!eagle.uis.edu!wendlingReferences:
<4160qb$g6b@warp.cris.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!eagle.uis.edu!wendling From: wendling@eagle.uis.edu (William Wendling) Newsgroups: comp.std.c Subject: Re: Help Needed...openiong/closing files... Date: 21 Aug 1995 04:12:13 GMT Organization: Sangamon State University Message-ID: <41912t$l70@eagle.uis.edu> References: <4160qb$g6b@warp.cris.com> NNTP-Posting-Host: eagle.uis.edu X-Newsreader: TIN [version 1.2 PL2]