🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3899

Help Needed...openiong/c

#3899
From: Night Rider
Date: Wed, 30 Aug 1995 17:53
49 lines
1984 bytes
-=> Quoting William Wendling to All <=-

 WW> From: wendling@eagle.uis.edu (William Wendling)
 WW> Organization: Sangamon State University

 WW> Mike Chilcott (mikechil@cris.com) wrote:
 WW> }    I am new at programming, and have a little problem.
 WW> } I have a huge file (over 90+meg). It is broken down into
 WW> } records of 923 characters each. Each record consists of 
 WW> } 30+ fields of varying size lengths.

 WW> }    I want to open the file, read a record and assign each 
 WW> } field a variable name. I then want to open an output file,
 WW> } and write certain fields to it.

 WW> }    I have been told to try and use STRUCTS, but am 
 WW> } having problems, understanding and implementing.
 WW> } Any help is appreciated....

I am new to C myself, but the basics don't change between languages much.

What you want to do is open the file in BINARY mode.
I am not sure the exact syntax but the example below should give you the idea.

struct MYFILE
{
  char FirstField[30];  /* Whatever size you need as character */
  int SecondField;  /* 2 bytes as integer */
  char ThirdField[891];         /* once you have accounted for all the _
        fields you close your struct */
};

now you just use your struct MYFILE to read in blocks from the file, and then
just access your variables in the struct like this

char NAME[30];
int NumberOfChildren;

NAME = MYFILE.FirstField;
NumberOfChildren = MYFILE.SecondField;

this should give you an idea of how to handle your file with structs, I would
like to give you more info, but I am new to C myself.

-={Dave Reid}=- 

... A feature is a bug with seniority.

___ Blue Wave/QWK v2.20 [NR]
Technical Details
Message-ID: <a96_9509011953@ship.net>
Path: arc1-ca.pugleaf.net!vanbc.wimsey.com!ship!nyqsoft!night.rider

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!vanbc.wimsey.com!ship!nyqsoft!night.rider
From: Night.Rider@nyqsoft.ship.net (Night Rider)
Date: 30 Aug 95 17:53:00 
Newsgroups: comp.std.c
Subject: Help Needed...openiong/c
Message-ID: <a96_9509011953@ship.net>
X-FTN-To: William Wendling
Organization: S2S Mail Machine