[fpc-pascal] Subscript pointers

Hairy Pixels genericptr at gmail.com
Thu Jun 22 15:23:13 CEST 2023


I've forgotten entirely, what does subscripting a pointer do in Pascal? p[0] returns 100 but after that garbage. Seems like a c-style array which doesn't feel right in the language.

var
  i: Integer;
  p: PInteger;
begin
	p := @i;
	p^ := 100;
	writeln(p[0]);
	writeln(p[1]);
	writeln(p[2]);

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list