|
Post by fwiss on Feb 28, 2011 10:17:44 GMT -5
This program worked like I wanted until I made the CLASS_CHOOSE Function. I can't even tell what's wrong but it seems like the function's not editing the array elements outside of itself, but I'm not sure. Can anybody help, I'm not sure of the problem? Attachments:
|
|
|
Post by matthew on Mar 1, 2011 9:42:30 GMT -5
Have you thought about using a Linked List to store the different attributes of the players. I think that would solve a lot of your problems.
|
|
|
Post by DJLinux on Mar 1, 2011 9:51:59 GMT -5
After a short view over your code here are a hint
you are using BYVAL
int CLASS_CHOOSE(signed int a, signed int b, signed int c, signed int d, signed int e, signed int f, signed int g, char h)
but if you will change the params it must be BYREF
int CLASS_CHOOSE(signed int &a, signed int &b, signed int &c, signed int &d, signed int &e, signed int &f, signed int &g, char h)
thats all
Joshy
|
|
|
Post by fwiss on Mar 1, 2011 10:16:25 GMT -5
DJLinux, your BYREF method worked, but I don't know why. Could you please explain it to me? I understand elementary pointers, but this is strange. I should be changing values, not references, and I am, but I'm using &, which is the reference operator.
|
|
|
Post by DJLinux on Mar 1, 2011 21:34:20 GMT -5
[pseudo code] void change_me1(int param_byval) { param_byval+=1; }
void change_me2(int ¶m_byref) { param_byref+=1; }
main(){ int a=1; int b=1; change_me1(a); printf(" a is now %d \n",a);
change_me2(b); printf(" b is now %d \n",b); } a copy of var "a" pushed on the stack and can't be changed inside of change_me1() a referenc (of course the address of) "b" pushed on the stack and will be incremented inside of change_me2() Joshy
|
|