Using GNAT I/O
MC logo

Using GNAT I/O

Ada Code Examples

<<Hello, World! Download Numeric constants and expressions>>
-- This is one of the examples shipped with GNAT.
With Gnat.IO; use Gnat.IO;
procedure Gnatioex is
   C : Character;
   I : Integer;
   S : String (1 .. 100);
   Put_Line ("Hello. Welcome to the GNAT IO example" & "!");
   Put ("Note: This example uses GNAT.IO which does not raise Data_Error");
   Put_Line (" for bad data.");
   Put ("      ");
   Put_Line ("For that you need to use the standard package Ada.Text_IO.");
   Put ("Please enter a single character now followed by <CR> ");
   Get (C);
   Put ("Your character is: ");
   Put (C);
   Get (C);  --  read the <CR>
   New_Line (2);

   Put ("Please enter a String now followed by <CR> :");
   Get_Line (S, I);
   Put ("Your String is : ");
   Put_Line (S (1 .. I));
   Put ("Its length is : ");
   Put (I);
   New_Line (2);

   Put ("Please enter an integer now followed by <CR> ");
   Get (I);
   Put ("Your number is: ");
   Put (I);
   New_Line (2);
<<Hello, World! Numeric constants and expressions>>