How can I use a variable that I have calculated previous in my program as an array index? I mean how can i make it constant? Could you give me an example?
You have, but I think I haven't express my answer
correct. ;-)
> I just want to use the variables value to declare
> the size of the array.
I understand, but you cannot do this. The compiler
has to know the exact size of the array _before_
the program is executed because the memory for
a static array is reserved when the program is
loaded. And the only way to do this is to use a
constant value.
If you do not know the exact size of your array
you may use the operator "new".
Another 'workaround' is to define an array with
a maximum size, calculate and save its exact size
somewhere and use it as an upper bound in your
iterations.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.