Pascal Resizing and Releasing Memory - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Saturday, September 23, 2017

Pascal Resizing and Releasing Memory

Write an Pascal Program For  Resizing and Releasing Memory

Program:
program exMemory;
var
name: array[1..100] of char;
description: ^string;
desp: string;

begin
name:= 'Zara Ali';
desp := 'Zara ali a DPS student.';

description := getmem(30);
if not assigned(description) then
writeln('Error - unable to allocate required memory')
else
description^ := desp;

(* Suppose you want to store bigger description *)
description := reallocmem(description, 100);
desp := desp + ' She is in class 10th.';
description^:= desp;

writeln('Name = ', name );
writeln('Description: ', description^ );

freemem(description);
end.

Output:
Name = Zara Ali

Description: Zara ali a DPS student. She is in class 10th

No comments:

Post a Comment