A problem in converting C code

Ali Çehreli acehreli at yahoo.com
Tue Nov 2 23:02:42 UTC 2021


On 11/2/21 3:57 PM, Ali Çehreli wrote:

Here is a more idiomatic version:

import std.stdio;
import std.string;

void main() {
   const x = strip(readln());
   writeln(x);

   if (x == "hello world!") {
     writeln("yes");
   }
}

The first line in main can be written with UFCS syntax as well:

   const x = readln.strip;

Ali



More information about the Digitalmars-d-learn mailing list