http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

TheGrumpyProgrammer



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic arrays



Malloc, free, and realloc are the standard way to do this. You declare a
pointer to a vector of tyhe data type you want and then malloc a chunk
of memory with a size of (sizeof(my_struct_type) * length_of_vector.
When you want to add to the end of the vector just realloc() the memory
to the new size.

		Bob P.


dakline@vassar.edu wrote:
> 
> Here's a topic that comes up all the time. How do you allocate the size of
> an array after a program has been started. I know you can change the size
> of STL vectors but that's not what I want. I imagine it has something to do
> with the char* format, using null-terminated strings maybe, but that won't
> work for other data types, and the method behind it is mysterious to me.
> 
> Would someone mind giving the topic a rundown for me?
> 
> thanks,
> SirFern
> 
> =================================================================
> The GameProgrammer.Com mailing list is for the open discussion
> of any topic related to the art, science, and business of
> programming games. This list is especially tolerant of beginners.
> We were all beginners once
> 
> To SUBSCRIBE or UNSUBSCRIBE please visit:
> http://gameprogrammer.com/mailinglist.html
=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html