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

Initializing Variables

Part of TutorialFundamentals

Description

Shows how to initialize an integer and a string.

Example

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 function, except that it will append a newline to the end of its output. So writefln("text") is equivalent to writef("text\n").