Given a file input.txt
, which consists of a number of elements in arrays and elements in the arrays, I should read the data and copy it to arrays in Eiffel. For example, for
3
3 4 5
2 3 1
I should get len = 3
, a1 = {3,4,5}
, a2 = {2,3,1}
.
I have tried the following but it was not successful
take_input
-- Read user's input.
local
input: PLAIN_TEXT_FILE
output: PLAIN_TEXT_FILE
itr: INTEGER
do
create input.make_open_read ("input.txt")
input.read_integer
len := input.last_integer
create output.make_open_write ("output.txt")
create num.make_filled (0, 1, len)
create rem.make_filled (0, 1, len)
from
input.start
input.read_integer
itr := 0
until
input.off
loop
itr := itr + 1
if itr <= len then
num [itr] := input.last_integer
input.read_integer
else
rem [itr - len] := input.last_integer
input.read_integer
end
end
input.close
end
Here Is there any way I can continously read the inputs rather than again starting from the Begginning of the file?