Coder's Guild Mailing List

Re: dynamic array

Posted by maranhao on 1998-03-19

At 04:43 AM 3/19/98 +0100, you wrote:
>
>>
>> A dynamic array is used when you need to declare an array after the
>program
>> has started. For example if you wanted to know how many elements would
>be
>> needed for the array, then you could ask the user then create one
>> dynamically. Here's how to create a dynamic array of integers in C++.
>>
>> int *array // Pointer to the first element in the array
>> int n = 10; // number of elements in the array
>>
>> array = new int[n];
>>
>> the pointer array can be accesed just like a normal array even though
>it's a
>> pointer, ex. array[1], array[8] ect..
>>
>> --Dave
>>
>
>i only know how to read C++ but i don't program in it. How would you have
>the same effect in Turbo Pascal?
>-Reice
>
>

I don't know much about pascal, just the basics. It should be the same idea
to it though. All your doing is allocating memory thats big enough to fit
your array into it. If there's a command in pascal that allocates a
specific number of bytes in memory, then you can do it.