A problem in converting C code
pascal111
judas.the.messiah.111 at gmail.com
Tue Nov 2 22:36:21 UTC 2021
In next program I intend it to be the D version of a C program,
but I found some troubles with it, can we keep the C style of it
as it is as we can and fix the must-be-fixed parts to make it
works under D compiler?
// D programming language
import std.stdio;
import core.stdc.stdio;
import core.stdc.string;
int main()
{
char x[20];
fgets(&x[0],x.sizeof,null);
x[strcspn(&x[0],"\n")]=0;
writeln(x);
if(!strcmp(&x[0],"hello world!"))
{
writeln("yes");
}
return 0;
}
More information about the Digitalmars-d-learn
mailing list