Mail Archives: djgpp/2005/04/09/19:23:13
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
Message-ID: | <BAYC1-PASMTP01C1CD2938CB47905898FAEF300@cez.ice>
|
X-Originating-IP: | [70.50.143.180]
|
X-Originating-Email: | [april_white AT sympatico DOT ca]
|
Message-ID: | <42585FA4.7010903@sympatico.ca>
|
Date: | Sat, 09 Apr 2005 19:05:08 -0400
|
From: | April White <april_white AT sympatico DOT ca>
|
User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3
|
X-Accept-Language: | en-us, en
|
MIME-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
Subject: | Re: problem with saving struct to disk
|
References: | <129 DOT 5a9df4a1 DOT 2f89aa98 AT cs DOT com>
|
In-Reply-To: | <129.5a9df4a1.2f89aa98@cs.com>
|
X-OriginalArrivalTime: | 09 Apr 2005 23:08:03.0390 (UTC) FILETIME=[FB62CDE0:01C53D58]
|
Reply-To: | djgpp AT delorie DOT com
|
KTrumpetsRule AT cs DOT com wrote:
>I'm having a problem saving a struct to disk using DJGPP. Normally I'd think
>the problem was me but in view of the fact that it works under SOME
>circumstances, I'm not sure. Here's the details.
>
>
>
looks like someones homework :-)
The problem seems to be that you are accepting a POWER * parameter for
the i/o functions, but you are then using
> fwrite(&power_0, sizeof(power_0), 1, ptr_file);
>
>
and
> fread(&power_0, sizeof(power_0), 1, ptr_file);
>
>
You seem to be saving the pointer to the POWER structure, not the POWER
structure itself.
I've not compiled this, but try
fwrite(power_0, sizeof(*power_0), 1, ptr_file);
and
fread(power_0, sizeof(*power_0), 1, ptr_file);
The first param to fread() and fwrite() is a pointer to a thing, which
power_0 is. The second param is the size of one of those things
April
--
Eat well, stay fit, die any way.
- Raw text -