Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about changing my data structure

Author: Uri Blass

Date: 06:03:33 07/17/03

Go up one level in this thread


On July 17, 2003 at 07:01:10, Dave Gomboc wrote:

>On July 17, 2003 at 05:06:16, Uri Blass wrote:
>
>>Note that the name of the arrays that I have is different but I replaced the
>>names to make it easy to understand the problem.
>>
>>I have an array A[64][8]
>>
>>I want to replace it by 8 arrays A0[64],A1[64],...A7[64] when A[i][j]=Aj[i]
>>
>>What is the best way to do it?
>
>
>I think you want something like
>
>    typedef /* your type here */ element_type;
>
>    element_type big_array[8][64];
>    const element_type zeroth_array [64] = big_array[0];
>    const element_type first_array  [64] = big_array[1];
>    const element_type second_array [64] = big_array[2];
>    const element_type third_array  [64] = big_array[3];
>    const element_type fourth_array [64] = big_array[4];
>    const element_type fifth_array  [64] = big_array[5];
>    const element_type sixth_array  [64] = big_array[6];
>    const element_type seventh_array[64] = big_array[7];
>
>Then you can refer either to big_array[0][n] or to zeroth_array[n].
>
>The syntax is probably not exactly correct, my machine is busy so I didn't put
>it through a compiler.

You are right that the syntex is not correct.
When I use int instead of element type I get the error

array initialization needs curly braces

Maybe I need the following syntex except using significant names to the array
and not big_array, zeroth_array,...:

int big_array[8][64];
int * const zeroth_array = big_array[0];
int * const first_array = big_array[1];

Uri



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.