Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates


[D] Hello World Tutorial

hello world

  • Please log in to reply
6 replies to this topic

#1 Termana


    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 971 posts

Posted 02 January 2009 - 05:41 AM

I am going to assume you have followed all the steps to my previous tutorial - "How to setup DMD"
1. Open up a new text file.

2. In the text file type:
import std.stdio;
this will allow you access to the std.stdio module of the standard library, which is the standard input and output module.
int main()
if you have past coding experience, you will know this is the starting point of the program.
std.stdio.writefln("Hello World!");
This writes the line "Hello World" to the console, for C or C++ coders, writefln is alot like printf, you can use it in the same way.
return 0;
This will read the line inputted into the console, just makes it so that you have to press enter before the console window closes. And "return 0;" returns the function with the number 0. In the case of the main function, this just lets the OS know that the program has run sucessfully.

3. Save the text file as helloworld.d in C:\ (or whatever your main drive is).

4. Go to Start -> Run and type in cmd.

5. At the command prompt type in "dmd -release -O -inline C:\helloworld.d"

6. You can now run your Hello World program by going to My Computer -> C:\ and double clicking helloworld.exe

In the code you can just use writefln and readln rather then std.stdio.writefln and std.stdio.readln, however I do like to use the whole name.
  • 5

Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!

#2 Guest_Jordan_*

  • Guest

Posted 02 January 2009 - 07:48 AM

Nice tutorial. The syntax looks just like C++. +rep
  • 0

#3 mendim.


    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 741 posts

Posted 02 January 2009 - 09:51 AM

Nice One Termana .. +rep . :D
  • 0

#4 whitey6993


    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 156 posts

Posted 02 January 2009 - 03:25 PM

Good tutorial. +rep
  • 0

#5 Egz0N


    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1155 posts

Posted 02 January 2009 - 04:04 PM

nice tutorial .. +rep :)
  • 0

#6 amina


    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 08 January 2009 - 04:07 AM

Nice tutorial.Thanks for share it with us.its very nice of you to help some one else with your tutorial.I am waiting for your next post.Thanks again...
  • 0

#7 Guest_Jordan_*

  • Guest

Posted 09 January 2009 - 03:10 PM

I'm curious - how did you come by and why did you choose to learn D?
  • 0

Also tagged with one or more of these keywords: hello world

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download