Logo

Programming-Idioms

History of Idiom 22 > diff from v90 to v91

Edit summary for version 91 by hyhhh:
[Ada] sffsfsfsfssfsfsfs

Version 90

2020-02-12, 09:39:44

Version 91

2020-02-12, 09:40:49

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration
Extra Keywords
int base conversion
Extra Keywords
int base conversion
Code
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Test is
subtype Small is Integer range 0..99;
Input : Small;
begin
loop
Get(Input); 
if Input = 42 then
exit;
else
Put (Input);
New_Line;
end if;
end loop;
end;
Code
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Test is
subtype Small is Integer range 0..99;
Input : Small;
begin
loop
Get(Input); 
if Input = 42 then
exit;
else
Put (Input);
New_Line;
end if;
end loop;
end;