writef
Part of StandardLibraryCategory
Description
Since DMD 0.95, writef is available as a replacement for printf. (Access Violations can become a thing of the past.)
Example
import std.stdio; void main() { /* Integers */ int i=123; writef(i, \n); /* prints "123" */ writef("%s", i, \n); /* prints "123" */ writef(\n); writef("Leading zeros\n"); /* prints "123" (would have a leading zero or zeros if necessary) */ writef("%02s", i, \n); /* prints "123" (would have a leading zero or zeros if necessary) */ writef("%03s", i, \n); /* prints "0123" (leading zero) */ writef("%04s", i, \n); /* prints "00123" (leading zeros) */ writef("%05s", i, \n); /* Reals */ real x = 1.0; writef(x, \n); writef("%f", x, \n); /* from digitalmars.D.bugs:894 */ printf( "%Lf\n", x ); x = 2.345; writef(x, \n); writef("%f", x, \n); /* from digitalmars.D.bugs:894 */ printf( "%Lf\n", x ); }
More Information
Find more details in the official docs.
Source
Link | http://www.dsource.org/tutorials/index.php?show_example=105 |
Posted by | jcc7 |
Date/Time | Wed Dec 15, 2004 2:31 pm |