From: | Stephen Illingworth |
Date: | 23 Aug 2001 at 16:36:30 |
Subject: | [amiga-c] Re: Saving and reading structs |
Hello Jack
On 23-Aug-01, you wrote:
> Hello,
>
> I have a declaration of something like
> struct mystruct
> {
> struct Node nn_Node;
> BOOL a;
> LONG b;
> STRPTR c;
> struct List *d;
> }mystruct;
>
> I allocate STRPTR c as needed so its strlen will vary with each instance
> of mystruct. I wanted to be able to save the struct to disk with
> fwite(&mystruct, sizeof(struct mystruct)...
> but that won't work because of the varying length. Any suggestions on
> what's the best way to save this?
Varying length has nothing to do with it, it won't work because
you're only writing the pointer values, and not the data the
pointers point to.
I'm afraid the only way to do this correctly, is to save the
structure member by member.
Regards
Steve
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get VeriSign's FREE GUIDE: "Securing Your Web Site for Business." Learn about using SSL for serious online security. Click Here!
http://us.click.yahoo.com/KYe3qC/I56CAA/yigFAA/dpFolB/TM
---------------------------------------------------------------------~->
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/