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

Get a number from the user (uses scanf)

Part of TutorialFundamentals

Description

Shows how you can ask the user for a number during runtime.

Example

import std.stdio; /* for write/writefln */

int main() 
{
    double n;

    write("Pick a number: ");
    scanf("%lf", &n);

    writefln("You picked: %s", n);
    return 0;
}