Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: c++ code question

Author: Sven Reichard

Date: 01:55:34 11/26/03

Go up one level in this thread


On November 25, 2003 at 00:05:16, Russell Reagan wrote:
>above. When you do:
>
>SomeMove = AllMoves[8]; // get the 9th move
>
>That is the same as:
>
>SomeMove = *(AllMoves + (8 * sizeof(Move)))

Erm... not to add to the general confusion, but this is not correct. Pointer
arithmetic in C/C++ takes into account the size of the objects pointed to.
Hence, the first line above is equivalent to

SomeMove = *(AllMoves + 8);

//If you want, this is in turn equivalent to
//
//SomeMove = *(Move*)(((void*) AllMoves) + 8*sizeof(Move));
//
//but we don't need to bother about that, since the compiler does the
//"right thing".

Sven.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.