I am trying to iterate through chars and print them using Put_Line()
function but it takes String parameters, not chars. Is it possible to convert char to String like I can do it with Integer using 'Image()
? My code:
with Ada.Text_IO;
use Ada.Text_IO;
procedure Main is
begin
for I in 'A' .. 'Z' loop
Put_Line(I);
end loop;
end Main;
Your problem is not only Character conversion but you need also to inform compiler what kind of Character you will use, and yes, you can use Image attribute to get String representation of a char.
with Ada.Text_IO;
use Ada.Text_IO;
procedure Main is
begin
for I in Character range 'A' .. 'Z' loop
Put_Line(I'Image);
end loop;
end Main;
This code will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With