V
V
Vladislav2015-10-03 20:20:33
Programming
Vladislav, 2015-10-03 20:20:33

The compiler swears at the function. What should I do?

Comrades!
The compiler swears at a function that should return an array of integers.
Really in Turbo Pascal function can return only standard data type??

function NewMassive(a:mass;x,y:integer):array [1..100] of integer;
var
  i,c:integer;
  b:mass;
begin
  c := 1;
  for i := x to y do begin
    b[c]:= a[i];
    c:=c+1;
  end;
  NewMassive := b;
end;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2015-10-03
@Hateman31

When there are two complex structures, you need to set parameters in a procedure, not a function. Because functions are used to return simple types.
Correct like this:

procedure Some(a: mass; var b: mass)
begin
end;

Parameter a - input array. b - configured to exit.

Z
zed, 2015-10-03
@zedxxx

To return a data type, it must be declared. Apparently, you have already declared the type of a dynamic array - mass, so you need to return it:
And your array bis not initialized. He must first set the size, and only then write something into it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question