I would like to have a function, that when called creates a new stack, do some operations and then disposes the memory it used for stack. How can I do that?
I implemented my stack using an array:
Type stack = record
T :array[1..100] of integer;
top:Integer
end;
Edit: I want to use the stack in a function, and I want it to be local.
If I do
function A()
var S:stack
begin
code();
end;
Will it dealocate the memory after the variable S once the funcion is done, or do I have to take care of it?