Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Where can I find the equivalent of “printf” in Ada?

ADA equivalent printf
0
10 Posted

Where can I find the equivalent of “printf” in Ada?

0

While the standard package Text_IO provides many features, the request for a printf-like function is not unusual. (solution based on a suggestion by Tucker Taft) It is possible to produce a printf-like capability by overloading the “&” operator to take an object of type Format and an object of some type and return the Format, properly advanced, after having performed the appropriate output. The remaining format can be converted back to a string–e.g. to examine what is left at the end of the format string– or simply printed to display whatever remains at the end.

0

While the standard package Text_IO provides many features, the request for a printf-like function is not unusual.(solution based on a suggestion by Tucker Taft)It is possible to produce a printf-like capability by overloading the “&” operator to take an object of type Format and an object of some type and return the Format, properly advanced, after having performed the appropriate output. The remaining format can be converted back to a string–e.g. to examine what is left at the end of the format string– or simply printed to display whatever remains at the end.

0

While the standard package Text_IO provides many features, the request for a printf-like function is not unusual. (solution based on a suggestion by Tucker Taft) It is possible to produce a printf-like capability by overloading the “&” operator to take an object of type Format and an object of some type and return the Format, properly advanced, after having performed the appropriate output. The remaining format can be converted back to a string–e.g. to examine what is left at the end of the format string– or simply printed to display whatever remains at the end. For example: with Text_IO; package Formatted_Output is type Format is limited private; function Fmt (Str : String) return Format; function “&” (Left : Format; Right : Integer) return Format; function “&” (Left : Format; Right : Float) return Format; function “&” (Left : Format; Right : String) return Format; … — other overloadings of “&” procedure Print (Fmt : Format); function To_String (Fmt : Format) return String; priva

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.