0

I am practicing Ada and made a simple program that prints a word and an integer. The problem is that the console output looks like:

Yes        55

When I want it to look like:

Yes55

I do not know why there is a giant space, here is my code:

WITH Ada.Text_IO; USE Ada.Text_IO;

PROCEDURE Practice IS
   PACKAGE MyInt_IO IS NEW Ada.Text_IO.Integer_Io(Integer);
   USE MyInt_IO;   
BEGIN
   Put("Yes"); Put(55);
END Practice;

Thanks!

Numnumberry
  • 415
  • 4
  • 16
  • 3
    Possible duplicate of [*Is there a way to format text output in Ada*](http://stackoverflow.com/questions/6032210/is-there-a-way-to-format-text-output-in-ada). – trashgod Jan 29 '17 at 06:52
  • 1
    Possible duplicate of [*Cancel space after* `Integer'Image` *value in Ada*](http://stackoverflow.com/q/1846737/230513). – trashgod Jan 29 '17 at 06:53
  • It places enough spaces to hold any value of that type (including any +/- signs). You'll see a larger gap if you use Long_Integer, and a much shorter one if you create a new type (e.g. type Short is range 1..10) and instantiate Integer_IO with that new type. – Dale Stanbrough Jan 31 '17 at 05:55

1 Answers1

1

There is a large space in order to right-align the numbers when printing in the console (in order to make it easier to compare them if you were to print many lines).

If you want to remove it, you can use Width parameter in Integer_IO.Put to set a minimal size of zero:

Put(55, Width => 0);
Faibbus
  • 1,115
  • 10
  • 18