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

Wait

Part of TutorialFundamentals

Description

Demonstrates several ways to wait for the user to press a key. (Designed for Windows).

Example

import std.c.stdio; /* for getch() */
import std.process; /* for system() */
import std.stdio; /* for writefln */

void main() { 
    writefln("Press a key (using 'std.c.stdio.getch();' to wait) . . .");
    getch();

    writefln("Waiting again\n(using 'system(\"pause\");'):");
    system("pause");
}

Sample Batch File

@echo off
set pgm=WaitExample
dmd %pgm%.d
%pgm%.exe
pause
erase %pgm%.obj
erase %pgm%.map

Tested Versions

Tested with Digital Mars D Compiler v1.0 on Windows 2000.