pchar

When can ((Pointer)(P)+1)^ work?

一曲冷凌霜 提交于 2019-12-10 19:48:38
问题 I'am working on delphiXE2 and i was working on PInteger. if i did this in my delphi code var P: PInteger; testInt: Integer; Scores: array[0..4] of Integer=(33,44,56,78,78); begin P := @Scores; testInt := (P+1)^; WriteLn(testInt); ReadLn; end; I got this error. [DCC Error] Project1.dpr(23): E2015 Operator not applicable to this operand type PS: testInt := (P+1)^; is the 23rd line However when I try this var PCh: PChar; testchar: char; str: array[0..4] of char=('a','b','c','d','e'); begin PCh :

In Delphi in my DLL do I have to allocate the return pchar of a function

北城余情 提交于 2019-12-04 18:53:59
问题 I have a DLL in which I have a function that returns a pchar. (as to avoid having to use borlndmm) What I was doing originally was casting a string as a pchar and returning that Result := pChar(SomeFuncThatReturnsString) But I was getting expected results 90% of the time and the other times I would get back nothing. I then got to thinking that I needed to allocate the memory for the pchar and that doing it my original way was having a pchar point to memory that was not always going to be what

In Delphi in my DLL do I have to allocate the return pchar of a function

早过忘川 提交于 2019-12-03 12:55:59
I have a DLL in which I have a function that returns a pchar. (as to avoid having to use borlndmm) What I was doing originally was casting a string as a pchar and returning that Result := pChar(SomeFuncThatReturnsString) But I was getting expected results 90% of the time and the other times I would get back nothing. I then got to thinking that I needed to allocate the memory for the pchar and that doing it my original way was having a pchar point to memory that was not always going to be what was there when the function was called originally. So I now have this Result := StrAlloc(128); Strcopy