I'm working in Borland Delphi, and i have a few lines code in Borland C++ Builder. I would like to translate these lines into Delphi source.
unsigned char *buf=NULL;
buf=new unsigned char[SPS*2];
for (i=0; i<SPS*2; i++)
buf[i]=2;
... ....
answers=buf[2];
I would like to assign a PCHar value with this buf;
a:PCHar;
a:=buf.
Perhaps like this:
var
buf: array of AnsiChar;
a: PAnsiChar;
...
SetLength(buf, SPS*2);
FillChar(buf[0], Length(buf), 2);
a := @buf[0];
No idea what answers
is, but, assuming it is a char
in your C++ code then you would write it like this:
var
answers: AnsiChar;
...
answers := buf[2];