[huskerlug] Re: More of a GCC problem.

  • From: "Jon Richardson" <jonpaulrichardson@xxxxxxxxxxx>
  • To: huskerlug@xxxxxxxxxxxxx
  • Date: Tue, 18 Mar 2003 16:52:22 +0000


Thanks guys... I think i'll just avoid variable length arrays for now until 
I master gcc.

Ceasar: the value iBalance changes between the declaration and the code 
snipet I gave.  In this particular case iBalance is 2.

It makes much more sense to use vectors so I think I'll start using them.  
Who knows maybe I'll end up switching compilers again, least my code will be 
portable :)


Thanks again for the help!






>From: cdelgad2@xxxxxxxxxxxxxx
>Reply-To: huskerlug@xxxxxxxxxxxxx
>To: huskerlug@xxxxxxxxxxxxx
>Subject: [huskerlug] Re: More of a GCC problem.
>Date: Tue, 18 Mar 2003 10:23:32 -0600 (CST)
>
>
> > > Am I doing something stupid I don't see?
> >
> > Yes, and no.  I think you do not understand how to use variable length
> > arrays.  You may also have a similarly defined array in which results
> > in
> > overwriting stack space.
> >
> > The link you provided says this:   "The length of an array is computed
> > once
> > when the storage is allocated and is remembered for the scope of the
> > array
> > in case you access it with `sizeof'."
> >
> > I believe, in your code, that means that the length is zero bytes long.
> > It
> > will NOT change when the value of the variable iBalance.   It works when
> > you
> > delare the array to be of size 100 because then you are allocating space
> > for
> > the array.
>
>Maybe what he wanted was something like "vector" instead of an array?  A 
>vector
>will "grow" as you add stuff to it so it's realy nice when you don't know 
>how
>many elements are going into the array.
>
>http://www.cppreference.com/cppvector.html
>
>-Cesar
>
>----
>Husker Linux Users Group mailing list
>To unsubscribe, send a message to huskerlug-request@xxxxxxxxxxxxx
>with a subject of UNSUBSCRIBE

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 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


Other related posts: