|
From: Ioannis V. <no...@ya...> - 2001-01-10 22:46:42
|
In C you can use malloc(), calloc() and realloc(). In C++ new and delete operators. Ioannis > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...]On Behalf Of Alan Thomas > Sent: Wednesday, January 10, 2001 5:01 AM > To: dev...@li... > Subject: [Dev-C++] dynamic array > > > How do you dynamically allocate space for an array? I have a > program that works but is awkward in one aspect and potentially slow (for > large input files). It performs operations on a file containing a > particular format of calendar entries. Because I did not wish to > initially > deal with dynamically allocating memory as I read in calendar entries, I > first read through the file just cueing on an end of entry character, to > count the number of entries. Then I declare an array of the appropriate > size, which will be used to hold processed information for each entry. > > This works fine for current input file sizes, but could slow > things down noticeably if the input file was an order of magnitude larger. > So, the alternative would be to allocate space as I read in entries. > > Thanks, Alan > > > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users > |