« Reply #15 on: June 13, 2021, 02:56:31 am »
It works!
No, it does not!
Here is why:
program Project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils
{ you can add units after this };
procedure test;
var
s:String;
pc:pchar=pchar($45454545);
begin
s:='ABC';
WriteLn('The fact: s=''',s,'''');
WriteLn('To point at the first letter in s...');
pc:=@s;
WriteLn('You think this works: @s --> ',pc^);
pc:=@s[1];
WriteLn('I think this works: @s[1] --> ',pc^);
end;
begin
test;
ReadLn;
end.
« Last Edit: June 13, 2021, 03:06:46 am by engkin »
Logged