I have identified
subtype String10 is String(1..10);
and I'm trying to get keyboard input without having to manually enter spaces before pressing the enter button. I tried get_line (), but for some reason, it actually didn’t wait for the input to get get put () output, and I also think that it will just leave everything on the line and not fill the space.
I know and used Bounded_String and Unbounded_String, but I'm wondering if there is a way to make this work.
I tried to make a function for it:
--getString10-- procedure getString10(s : string10) is c : character; k : integer; begin for i in integer range 1..10 loop get(c); if Ada.Text_IO.End_Of_Line = false then s(i) := c; else k := i; exit; end if; end loop; for i in integer range k..10 loop s(i) := ' '; end loop; end getString10;
but here I know that s(i) not working, and I do not think that
"if Ada.Text_IO.End_Of_Line = false then"
does what I hope he does. This is kind of just a placeholder while I'm looking for the actual way to do this.
I searched for a couple of hours, but the Ada documentation is not as accessible or transparent as other languages. I learned a lot about getting strings, but not what I'm looking for.
source share