Reputation: 395
I am doing a multi-stack program with opcodes that look like the following:
I2 Sam
I3 Bobby
I1 Steve
D3
I3 Jonathan
"I" means insert and the number is which stack, "D" means to delete and number is which stack. My question is, how do I read each of these from the command line and determine which operation to perform? The names are of variable length, and I cannot use heap memory. The one thing I can do is, since the list of possible names is known, is make the names into an enumeration type. Thanks!
Upvotes: 0
Views: 668
Reputation: 39638
If you are reading the values from standard input and are using at least Ada 2005, this method will work:
with Ada.Text_IO;
procedure Foo is
use Ada.Text_IO;
begin
while not End_Of_File loop
declare
Cur_Line : constant String := Get_Line;
begin
-- process the line here
end;
end loop;
end Foo;
Upvotes: 4