www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Equivalent to C++ iostream cout

reply Tommy <Tommy_member pathlink.com> writes:
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
Aug 02 2005
parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
"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);
Aug 02 2005
parent Tommy <Tommy_member pathlink.com> writes:
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
Aug 02 2005