delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/28/13:03:10

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Boy do I feel STUPID!! ....Files question...
Date: 28 Aug 1997 09:13:40 GMT
Organization: The National Capital FreeNet
Lines: 20
Message-ID: <5u3fg4$cvj@freenet-news.carleton.ca>
References: <Pine DOT SUN DOT 3 DOT 95 DOT 970827180028 DOT 18092B-100000 AT bert DOT eecs DOT uic DOT edu>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet6.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Andrew Deren (aderen AT eecs DOT uic DOT edu) writes:
> But you won't save char *name part of the structure. You only will save a
> pointer to that name. I would consider changing declarations in S_MAP to
> char name[15]; or whatever is the maximum number of chars in name.
> You have to be careful about saving structs to disk. You have to watch out
> for pointers inside the struct.

I know, I was answering the general question of how you write an array of
things to disk. Obviously, when there are embedded pointers, it is
necessary to do some fudge around it or other. Best is to either allocate
fixed-size strings, replacing that with char foo[nnn], or to use a record
by record disk write, with a function write_record(FILE *f, struct foo
bar) used to write one of struct foo to filestream f, and call it n times
from a loop.
--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019