Article View: comp.std.c
Article #3798Re: Help Needed...openiong/closing files...
From: Stephen Baynes
Date: Mon, 21 Aug 1995 08:51
Date: Mon, 21 Aug 1995 08:51
36 lines
2084 bytes
2084 bytes
William Wendling (wendling@eagle.uis.edu) wrote:
: 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
: FILE fo;
: fo=fopen("file", "rt");
^
't' here has no meaning in ANSI C.
: 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'.
If it is not a text file then fgets is probably the wrong function
to use.
: I suppose that you could have this being read into a structure of
: some sort.
You can read binary files directly into structs with fread. But
making the right structure for the file is implementation specific and
may not always be possible.
: --
: 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?
--
Stephen Baynes baynes@mulsoc2.serigate.philips.nl
Philips Semiconductors Ltd
Southampton My views are my own.
United Kingdom
Technical Details
Message-ID:
<DDnKM1.os@ukpsshp1.serigate.philips.nl>Path:
arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynesReferences:
<4160qb$g6b@warp.cris.com> <41912t$l70@eagle.uis.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) Subject: Re: Help Needed...openiong/closing files... Sender: news@ukpsshp1.serigate.philips.nl (account for localnews) Message-ID: <DDnKM1.os@ukpsshp1.serigate.philips.nl> Date: Mon, 21 Aug 1995 08:51:36 GMT References: <4160qb$g6b@warp.cris.com> <41912t$l70@eagle.uis.edu> Organization: Philips Semiconductors, Southampton, UK X-Newsreader: TIN [version 1.2 PL2]