Thread overview | |||||
---|---|---|---|---|---|
|
August 02, 2005 Equivalent to C++ iostream cout | ||||
---|---|---|---|---|
| ||||
Hi, is there an equivalent to C++ iostream's cout so that I can display several data types in a simple way such as int d = 10; double x = 0.4711; cout << "d is " << d << " and x is " << x << "."; I believe that D's function set in Phobos requires me to use different output functions for different data types which can be quite clumsy at times. Thanks, Tommy |
August 02, 2005 Re: Equivalent to C++ iostream cout | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tommy | "Tommy" <Tommy_member@pathlink.com> wrote in message news:dcojve$2h34$1@digitaldaemon.com... > Hi, is there an equivalent to C++ iostream's cout so that I can display several data types in a simple way such as > > int d = 10; > double x = 0.4711; > > cout << "d is " << d << " and x is " << x << "."; > > I believe that D's function set in Phobos requires me to use different output functions for different data types which can be quite clumsy at times. > > Thanks, > Tommy Are you looking for import std.cstream; dout.writef("d is ",d," and x is ",x,"."); Format control can be supplied with something like dout.writef("d is %5d and x is %.10e.",d,x); |
August 02, 2005 Re: Equivalent to C++ iostream cout | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | In article <dcon3r$2jii$1@digitaldaemon.com>, Ben Hinkle says... >Are you looking for > import std.cstream; > dout.writef("d is ",d," and x is ",x,"."); >Format control can be supplied with something like > dout.writef("d is %5d and x is %.10e.",d,x); Ah! Didn't understand the docs in this case. Thanks! Tommy |
Copyright © 1999-2021 by the D Language Foundation