0
我無法使用ReadAllCars函數讀取記錄數組。我如何才能將Car記錄的所有4個輸入讀入Cars陣列?我不斷收到動態數組錯誤。如何讀取數字以輸入數組和記錄的詳細信息?
type
cars = record
model:String;
year:integer;
end;
car = array of cars;
function readCar(prompt: String): Cars;
begin
WriteLn(prompt);
result.model := ReadString('Car Model: ');
result.year := ReadInteger('Year: ');
end;
**(this is my problem)**
function ReadAllCars(count:integer): Cars;
var
carArray: array of cars;
i:integer;
begin
setLength(carArray, count);
for i := 0 to high(carArray)do
begin
result.carArray[i] := readCar('Enter Car Details');
end;
end;
procedure Main();
var
cars: Array of Car;
begin
cars := ReadAllCars(4);
end;