> x = somefoo; > int blah[x]; > > I assume then I should never modify x again to ensure that this works > correctly and doesn't get overwritten? If so, that makes sense. This will ensure that your array is of size x. Changing x will have no affect AFTER the array is allocated, which occurs when the array comes into scope. Thus, in this case, the array will be of size x until you leave the function in which the array blah is declared, regardless of any subsequent changes to x. The length of the array is *variable* but NOT *dynamic*. The length of a vector is dyanamic because it is really just a linked list. Arrays provide faster access than linked lists (vectors) but do not provide dynamic size. In your original example, the array was declared with size 0. It worked the first time by overwriting the variable stored after the array (in the stack). Subsequent use of the variables declared after your array overwrote what you had written (which is fine since it is their space!). Hope this helps. Steve goddard@xxxxxxxxxxx ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dr. Steve Goddard Assistant Professor Room #215-A, Ferguson Hall Dept. of Computer Science and Eng. Phone: (402) 472-9968 University of Nebraska-Lincoln Fax: (402) 472-7767 Lincoln NE 68588-0115 Email: goddard@xxxxxxxxxxx WWW: http://www.cse.unl.edu/~goddard/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ----- Original Message ----- From: "Jon Richardson" <jonpaulrichardson@xxxxxxxxxxx> To: <huskerlug@xxxxxxxxxxxxx> Sent: Tuesday, March 18, 2003 10:59 AM Subject: [huskerlug] Re: More of a GCC problem. > > > Well... I'm still confused. I still don't understand why the value > iLabelNode[0] changes when it's not being modified, ok so I understand how > the space got overwritten but more or less why? The expected output of 4 > was given then it changes. The array did change size with iBalance. > > I think the way I'm using variable length arrays is wrong. > > Would the correct way be to declare a variable length array of size "x" and > not change x ever? > > example: > > x = somefoo; > int blah[x]; > > I assume then I should never modify x again to ensure that this works > correctly and doesn't get overwritten? If so, that makes sense. > > Anways, thanks again. > > Jon > > _________________________________________________________________ > MSN 8 with e-mail virus protection service: 2 months FREE* > http://join.msn.com/?page=features/virus > > > ---- > Husker Linux Users Group mailing list > To unsubscribe, send a message to huskerlug-request@xxxxxxxxxxxxx > with a subject of UNSUBSCRIBE > > ---- Husker Linux Users Group mailing list To unsubscribe, send a message to huskerlug-request@xxxxxxxxxxxxx with a subject of UNSUBSCRIBE