>From: "Alan Thomas" <ala...@3n...>
>Reply-To: dev...@li...
>To: <dev...@li...>
>Subject: [Dev-C++] RE: Dynamic Arrays
>Date: Fri, 12 Jan 2001 20:00:24 -0500
>
[SNIP]
>
> I think my original intent may have been lost in the past
>responses to my unclear inquiry. The situation I have is that I do not
>know the size of the array of a structure (an integer and several strings
>constitute one entry) I am reading from a file. Right now I read the file
>just to count the entries and then I declare the array, once I know its
>size. I wanted to be able to add another element of the array as I go. I
>also keep the entries in the order in which I read them, and I use another
>array to point to them in sorted order.
>
> Should I even be using arrays? If so, is what I described a
>"dynamic array" (expanding the size of the array as needed)? Does
>size_of_entry mean I have to declare some maximum size? If so, what am I
>saving by using new --- stack vs. heap space?
From what I saw of what you plan to do I would recommend using STL vectors.
They are almost exactly like arrays except they can grow as needed to hold
as much as your ram will allow. To find out more about vectors (And the rest
of the standard C++ template library) check out these websites..
http://www.ccd.bnl.gov/bcf/cluster/pgi/pgC++_lib/stdlib.htm
http://www.sgi.com/Technology/STL/
You can also do a search for "STL tutorial" on your favorite search engine
and probably come up with something
Chad Simmons
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
|