|
MKoD - D Programming Language
"Hello World!" example #1 - code-name Hello.d
"Hello World!" example:
// ** Hello.d **
private import std.stdio; // needed for writefln()
int main()
{
char[] s = "Hello World!";
writefln( "%s", s );
return 0;
} // end main()
C:\dmd\MKoD_ex>..\bin\dmd Hello.d
C:\dmd\bin\..\..\dm\bin\link.exe Hello,,,user32+kernel32/noi;
C:\dmd\MKoD_ex>Hello
Hello World!
C:\dmd\MKoD_ex>
"Hello World!" example #2 - code-name Hello_w_Args.d
Passing "Hello World!" into the console program as a parameter:
// ** Hello_w_Args.d **
import std.stdio; // needed for writefln()
int main ( char[][] args )
{
writefln( "Number of items=%d", args[].length );
for ( int ix = 0; ix < args[].length; ix++ )
{
writefln( "Args[ %d ]=\"%s\"", ix, args[ ix ] );
}
return 0;
} // end main()
C:\dmd\MKoD_ex>..\bin\dmd Hello_w_Args.d
C:\dmd\bin\..\..\dm\bin\link.exe Hello_w_Args,,,user32+kernel32/noi;
C:\dmd\MKoD_ex>Hello_w_Args "Hello World!"
Number of items=2
Args[ 0 ]="C:\dmd\MKoD_ex\Hello_w_Args.exe"
Args[ 1 ]="Hello World!"
C:\dmd\MKoD_ex>
|