Return the complete number
a11e99z
black80 at bk.ru
Wed Jul 24 16:14:19 UTC 2019
On Wednesday, 24 July 2019 at 15:45:08 UTC, Greatsam4sure wrote:
> int main(){
> double mum = 0;
> Write("enter a number: ")
> readf(" %s\n",&num);
> Writeln(num);
>
> }
>
> How do I return the complete number the user enter since I
> don't since the user can enter numbers of various length with
> dmd approximating it.
>
> I will appreciate any help
as drug said: writefln with formatting
in case no need prints just string representation use
s/format https://dlang.org/phobos/std_format.html#format
auto str = num.format!"%.16s"; // using UFCS
or
auto str = "%.16s".format( num); // UFCS too for 2nd version of
format
or
string str = format( "%.16s", num);
simple help can be asked on IRC channel too
irc://irc.freenode.net/d
(HexChat, mIRC clients and others)
More information about the Digitalmars-d-learn
mailing list