On Mon, Apr 27, 2009 at 11:29 PM, Jessie Morris
<[email protected]> wrote:
> On Monday 27 April 2009 9:23:13 pm Byron Clark wrote:
>> On Mon, Apr 27, 2009 at 08:52:20PM -0600, Jessie Morris wrote:
>> > file.write(reinterpret_cast<char *>(items),sizeof(int));
>>
>> Assuming that items is an int, you'll probably want &items instead of
>> items.
> That was EXACTLY what was wrong. But so that I understand what was going on,
> why is that needed?

file.write writes a block of memory pointed to by the first parameter.
&items gets the address of the int, so it passes in a pointer to its
value. Without it, write interprets the int as an address, and tries
to read an int from wherever it points.

Derek

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to