Re: A89: Matrix Errors


[Prev][Next][Index][Thread]

Re: A89: Matrix Errors




At 21:04 2001-02-11, you wrote:
>int lvl=1;
>int **hp = new int[lvl][2];

ehm.. new is a C++ construction...
And that is not his problem anyway, that line he doesn't want a new array, 
he just want an int with the value of stats[1][2]
The problem is that you cant initialize a new variable in C like he is 
trying in that code.
change to:

int hp,mhp,mp,mmp;
hp = stats[lvl][2];
mhp = stats[lvl][2];

and so on, instead.


>>I am having trouble using matrices.  If I declare a matrix and then try to
>>reference it the compiler gives me an error "Initializer value is not a
>>constant."  Heres the code:
>>
>>int stats[6][8]=
>>{{1,20,0,5,3,4,6,0},
>>{2,25,5,8,5,5,7,50},
>>{3,29,7,10,8,7,9,150},
>>{4,32,11,14,10,10,10,300},
>>{5,37,14,15,14,11,13,500},
>>{6,40,15,20,17,15,15,750},};
>>int lvl=1;
>>int hp=stats[lvl][2],mhp=stats[lvl][2],mp=stats[lvl][3],mmp=stats[lvl][3];
>>                        /\
>>                        | |
>>the error points to here
>>
>>and one more thing, this code is outside of all of my functions so it is
>>global, if that matters.  Can someone help me please?




References: