ex28.pp 560 B

123456789101112131415161718192021
  1. Program Example28;
  2. { Program to demonstrate the FreeMem and GetMem functions. }
  3. Var P : Pointer;
  4. MM : Longint;
  5. begin
  6. { Get memory for P }
  7. MM:=MemAvail;
  8. Writeln ('Memory available before GetMem : ',MemAvail);
  9. GetMem (P,80);
  10. MM:=MM-Memavail;
  11. Write ('Memory available after GetMem : ',MemAvail);
  12. Writeln (' or ',MM,' bytes less than before the call.');
  13. { fill it with spaces }
  14. FillChar (P^,80,' ');
  15. { Free the memory again }
  16. FreeMem (P,80);
  17. Writeln ('Memory available after FreeMem : ',MemAvail);
  18. end.