Reputation: 31
Im sorry to ask this question but Ada is really strict on an input and output system so I cant figure out how to get the input from a the user and put it into an array.
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada;
procedure Main is
type MY_ARRAY is array(1..9) of INTEGER;
Data : MY_ARRAY;
begin
Put("Please input the series of numbers");
Get_Line(Data);
end Main;
I know this is completely wrong but I research everywhere and I cant find how people get the input to an array LOL. Thank yall for help.
Upvotes: 2
Views: 7836
Reputation: 21
I think it's easier to use only the package Ada.Text_IO so that you can read each number as a String and then store it as an integer one by one using a for loop and Integer'Value
, which converts from String to Integer.
with Ada.Text_IO;
use Ada.Text_IO;
procedure Main is
type MY_ARRAY is array(1..9) of Integer;
Data : MY_ARRAY;
begin
Put_Line("Please input the series of numbers");
for I in 1..MY_ARRAY'Length loop
Data(I) := Integer'Value(Get_Line);
end loop;
end Main;
Upvotes: 2