Page 2 of 2

Re: PLI Dynamic array creation

PostPosted: Wed Jul 27, 2011 3:55 pm
by NicC
Looks like you have two distinct pieces of work - parse the xml file then process the output of that parsing. So, split the processing into 2 programs - the first doing your parse and saving a count of the elements to a file, the second reads the count, allocates the array with the count as the number of elements, read the parsed input into the array and process.

Re: PLI Dynamic array creation

PostPosted: Wed Jul 27, 2011 8:11 pm
by NicC
Another option: read the elements onto the stack - counting them as you do so. When all are read allocate the array using the count then move the items off the stack and into the array.

Re: PLI Dynamic array creation

PostPosted: Wed Jul 27, 2011 9:31 pm
by prino
Build a linked list, and at the end, when you have the count, allocate an array of pointers and let each pointer in that array point to the appropriate element of the linked list.