On 11/2/21 3:36 PM, pascal111 wrote:
can we keep the C style of it as it is
As you hint, this really is not D but still... :) I had to make three changes:
import std.stdio; // Ali - Importing stdin under a different name // to prevent name conflict with std.stdio.stdin; import core.stdc.stdio : c_stdin = stdin; import core.stdc.string; int main() { // Ali - Changed the type to char[20] char[20] x; // Ali - The last parameter is the stream // to read from. fgets(&x[0],x.sizeof,stdin.getFP()); x[strcspn(&x[0],"\n")]=0; writeln(x); if(!strcmp(&x[0],"hello world!")) { writeln("yes"); } return 0; } Ali