[huskerlug] Re: More of a GCC problem.

  • From: cdelgad2@xxxxxxxxxxxxxx
  • To: huskerlug@xxxxxxxxxxxxx
  • 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


Other related posts: