Jump to page: 1 24  
Page
Thread overview
March 25

Input:

void main()
{
    import std.stdio : writeln;
    writeln("Hello, World!\n");
    //I'm not sure if the ^^ is necessary or not
}

Output:

Hello, World!

That's it.

March 25
Welcome! :)

(We have a Learn forum (newsgroup) as well, where such posts are more suitable.)

On 3/25/22 13:07, Anonymous wrote:
> **Input:**
> ```d
> void main()
> {
>      import std.stdio : writeln;
>      writeln("Hello, World!\n");
>      //I'm not sure if the ^^ is necessary or not

It may be useful if you want an additional empty line. ;)

Otherwise, writeln is short form "write line", implying a newline will be printed at the end. (Conversely, write() does not add a newline.)

> }
> ```
>
> **Output:**
> ```
> Hello, World!
> ```
> That's it.

I like it! :)

Ali

March 25

On Hello, World! at some time, Anonymous wrote:

>

Input:

void main()
{
    import std.stdio : writeln;
    writeln("Hello, World!\n");
    //I'm not sure if the ^^ is necessary or not
}

Output:

Hello, World!

That's it.

Maybe this could be an added example for the example box found in the dlang homepage

March 26

On Friday, 25 March 2022 at 20:29:22 UTC, Ali Çehreli wrote:

>

It may be useful if you want an additional empty line. ;)

Otherwise, writeln is short form "write line", implying a newline will be printed at the end. (Conversely, write() does not add a newline.)

If a website was used to compile/output data, it might have truncated the newline(s). HTML afterall doesn't honor whitespacing. If it were preformatted aka then would honor the text formatting.

Using octal dump you could see the actual output.

$ ./test.exe | od -t c
0000000   H   e   l   l   o   ,       W   o   r   l   d   !  \r  \n  \r
0000020  \n
March 26

On Friday, 25 March 2022 at 20:07:39 UTC, Anonymous wrote:

>
void main()
{
    import std.stdio : writeln;
    writeln("Hello, World!\n");
}

Thank you...

I think this is a work of art. Just like the banana work that was attached to the wall with duct tape, which Italian sculptor Maurizio Cattelan called "Comedy".

Also, the end-of-line character is needed. In this way, there is the same number of characters as the line above. But I like this more:

     void main()
     {
          import std.stdio : writefln;
          "Hello".writefln!"%s, World!";
     }

Because it's functional...

SDB@79

March 28

On Saturday, 26 March 2022 at 04:03:08 UTC, Salih Dincer wrote:

>

Thank you...

I think this is a work of art. Just like the banana work that was attached to the wall with duct tape, which Italian sculptor Maurizio Cattelan called "Comedy".

Also, the end-of-line character is needed. In this way, there is the same number of characters as the line above. But I like this more:

     void main()
     {
          import std.stdio : writefln;
          "Hello".writefln!"%s, World!";
     }

Because it's functional...

SDB@79

Throwing my hat in the ring:

import std.stdio;
int main()
    => "Hello World".puts;
March 28

On Monday, 28 March 2022 at 05:23:22 UTC, FeepingCreature wrote:

>

Throwing my hat in the ring:

import std.stdio;
int main()
    => "Hello World".puts;

Report failure in case of success? :) (puts returns a "non-negative value" on success, which, with that wording, is not necessarily 0). Cute though.

March 28
On 3/28/22 06:33, Stanislav Blinov wrote:
> On Monday, 28 March 2022 at 05:23:22 UTC, FeepingCreature wrote:
>
>> Throwing my hat in the ring:
>>
>> ```d
>> import std.stdio;
>> int main()
>>     => "Hello World".puts;
>> ```
>
> Report failure in case of success? :)

We have precedent in rt_init: :)

  https://dlang.org/phobos/core_runtime.html#.rt_init

It is not obvious from its documented "returns 1/0" but it is a translation of Runtime.initialize's true/false:

  https://dlang.org/phobos/core_runtime.html#.Runtime.initialize

Ali

March 28
On Mon, Mar 28, 2022 at 01:33:55PM +0000, Stanislav Blinov via Digitalmars-d wrote:
> On Monday, 28 March 2022 at 05:23:22 UTC, FeepingCreature wrote:
> 
> > Throwing my hat in the ring:
> > 
> > ```d
> > import std.stdio;
> > int main()
> >     => "Hello World".puts;
> > ```
> 
> Report failure in case of success? :) (`puts` returns a "non-negative
> value" on success, which, with that wording, is not necessarily 0).
> Cute though.

This should fix the return code:

	import std.stdio;
	int main() => !(1 + "Hello World".puts);

:-P (Well OK, this is a hack, EOF is not necessarily -1. But it is on my
system.)


T

-- 
The computer is only a tool. Unfortunately, so is the user. -- Armaphine, K5
March 28

On Monday, 28 March 2022 at 05:23:22 UTC, FeepingCreature wrote:

>

On Saturday, 26 March 2022 at 04:03:08 UTC, Salih Dincer wrote:

>

Thank you...

I think this is a work of art. Just like the banana work that was attached to the wall with duct tape, which Italian sculptor Maurizio Cattelan called "Comedy".

Also, the end-of-line character is needed. In this way, there is the same number of characters as the line above. But I like this more:

     void main()
     {
          import std.stdio : writefln;
          "Hello".writefln!"%s, World!";
     }

Because it's functional...

SDB@79

Throwing my hat in the ring:

import std.stdio;
int main()
    => "Hello World".puts;
I'll try another

2 line version

import std.stdio;
void main() { "Hello World".writeln; } // Or "puts"
« First   ‹ Prev
1 2 3 4