Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: c++ code question

Author: Russell Reagan

Date: 21:05:16 11/24/03

Go up one level in this thread


On November 24, 2003 at 23:55:47, macaroni wrote:

>I want to parse the pointer of a move list into the function so it can be
>changed inside the function, the bottom of your two would parse it in to be used
>by the function wouldn't it?
>Lets say I use the top one. How would I then call MoveGenerator? with
>'MoveCount=MoveGenerator(turn, &AllMoves);' where allmoves is an array with 100
>elements? and if so, once inside the function MoveGenerator, how do I edit
>AllMoves (*List)?
>thanks for helping.

This is how I would do it, given your requirements.

int MoveGenerator ( int turn, Move * List );

Move AllMoves[100];

int MoveCount = MoveGenerator( turn, AllMoves );

It sounds like you're confused about what an array is. When you declare an
array, such as "Move AllMoves[100];", AllMoves is a pointer to an array of 100
elements of Move. So that is why you can just pass it to the function like I did
above. When you do:

SomeMove = AllMoves[8]; // get the 9th move

That is the same as:

SomeMove = *(AllMoves + (8 * sizeof(Move)))



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.