Amiga-C (173/223)

From:Jack York
Date:23 Aug 2001 at 08:11:02
Subject:[amiga-c] Re: Saving and reading structs

Hello Stephen

On 23-Aug-01, Stephen Illingworth wrote:

>> 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 understand it is only writing the pointer. I was trying to explain why
the STRPTR wasn't decaled as just char.

> I'm afraid the only way to do this correctly, is to save the
> structure member by member.

That's what I thought but I wanted to be sure. Thanks.

Jack



E-Mail: jyork@twmi.rr.com
Alt: jyork@voyager,net
Home: http://my.voyager.net/~jyork

------------------------ 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/