Hello,
I am really sorry for having missed a ^ in the program but you see , the program really worked in BP and not in GPC.But i do know that it is stupid to manipulate some parts of the pointer.kindly delete the previous mail. It is this program that i have problems in. ----------------- program typcast1; const ct :char='h'; type Mytype=record i : integer; c:^char; end; var p:pointer; begin getmem(p,sizeof(mytype)+2); fillchar(p^,sizeof(mytype)+2,0); word(p^):=sizeof(mytype); p:=pchar(p)+2; mytype(p^).c:=@ct; writeln(mytype(p^).c^); end. ------------------------
But if i change p:=pchar(p)+2; to p:=pchar(p)+4; then it works.Is it something to do with the word-boundaries?
Thanks and regards, Anuradha
Marco van de Voort wrote:
What is the purpose of these two lines : ? word(p):=sizeof(mytype);
In real mode TP it sets the offset of the segment:offset pair to 1.
Probably it originally was meant as a simple inc(p);
The problem it expects that the offset part of a newly allocated block is always zero, which is afaik not true. (real mode TP allocates per half segment).
p:=pchar(p)+2;
inc(p,2); or p:=@p[2];
The overall effect therefore is inc(p,3); or p:=pchar(p)[3];
-- S.Anuradha Generic Data Tools, Alcatel Chennai. Alcanet : 2-757-7123