Thread overview
Equivalent to C++ iostream cout
Aug 02, 2005
Tommy
Aug 02, 2005
Ben Hinkle
Aug 02, 2005
Tommy
August 02, 2005
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
"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
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