Note: This website is archived. For up-to-date information about D projects and development, please visit

Initializing Variables

Part of TutorialFundamentals


Shows how to initialize an integer and a string.


import std.stdio;

int magicNumber = 42;
string password = "sesame";

void main() {
  writefln("Magic number: %s", magicNumber);
  writefln("Password: %s", password);

More Information

Note the use of the writefln function, which is identical to writef except that it will append a newline to the end of its output. So writefln("blah") is equivelant to writef("blah\n").