|
From: Fabien V. <fv...@fr...> - 2001-01-10 11:31:14
|
With you're writting your program in C you can use: int (*buffer)[]; buffer=(int*)malloc(size_of_entry*sizeof(int)); Then you can use your variable "buffer" as you would do with any array. When you have finished to use your buffer do free(buffer); VIVES Fabien. ----- Original Message ----- From: "Alan Thomas" <ala...@3n...> To: <dev...@li...> Sent: Wednesday, January 10, 2001 4:00 AM 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 > |