Board index » delphi » Dynamic array sizes

Dynamic array sizes

Quote
ashley.dick...@health.gov.au wrote in message

<6v15j3$88...@nnrp1.dejanews.com>...

Quote
>In C the array operators allow blocks of memory to addressed as arays of
>whatever type you like. Is the same possible in Delphi? or do I need to use
>variants to achieve dynamic array sizing?

var
    a: array of someType;
...

SetLength(a, someinteger);

and there's a way to preserve the contents. Check 'dynamic array'
in online help What's New?

Quote
>Also is pointer arithmetic with pointers to types other than char possible?

Yes, but it's not necessary. Simply select each item with it's index
eg, a[i] is the i-th value (0-based).

--
 Grace + Peace | Peter N Roth | Engineering Objects Int'l
Books on: Delphi,  C++, Math, Engineering, Consulting, Life
                http://www.inconresearch.com/eoi

 

Re:Dynamic array sizes


Quote
ashley.dick...@health.gov.au wrote:
> In C the array operators allow blocks of memory to addressed as arays of
> whatever type you like. Is the same possible in Delphi? or do I need to use
> variants to achieve dynamic array sizing?

> Also is pointer arithmetic with pointers to types other than char possible?

> Cheers

> Ashley

Check out the currently active thread "Pointer-Problem".  I think It will
answer all your questions.

Bob Lee

Re:Dynamic array sizes


In C the array operators allow blocks of memory to addressed as arays of
whatever type you like. Is the same possible in Delphi? or do I need to use
variants to achieve dynamic array sizing?

Also is pointer arithmetic with pointers to types other than char possible?

Cheers

Ashley

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

Other Threads