Re:Pointer To Pointer...ACK!
Quote
Andrew Sprecher wrote:
> Hello All,
> I'm messing around with Delphi and am having trouble remembering my syntax
> for pointer to pointer etc...I want to create a pointer to an array of
> pointers to PChar strings.
> I manage to gracefully stomp all over memory and hang my machine no matter
> what syntax I use.
> Any help that would save me the trouble of rebooting my machine every 5
> minutes would help.
> Thanks
> Andy Sprecher
type
TPCharArray = array[0..2] of PChar;
PPCharArray = ^TPCharArray;
procedure TForm1.Button1Click(Sender: TObject);
var
p : PPCharArray;
begin
GetMem(p, sizeof(TPCharArray));
GetMem(p^[0], 32);
GetMem(p^[1], 32);
GetMem(p^[2], 32);
StrCopy(p^[0], 'Test1');
StrCopy(p^[1], 'Test2');
StrCopy(p^[2], 'Test2');
ShowMessage(p^[1]);
FreeMem(p^[0], 32);
FreeMem(p^[1], 32);
FreeMem(p^[2], 32);
FreeMem(p, sizeof(TPCharArray));
end;
--
Joe C. Hecht
Borland Delphi Developer Support Group
Technical Documents and Online Forums are available at
http://www.borland.com