I'm trying to follow a simple tutorial and can't get the following code to work:
void main(string args[])
{
auto f = File("test.txt", "w");
f.writeln("Hello, Worlds!");
}
I'm using the dmd compiler on windows.
I'm trying to follow a simple tutorial and can't get the following code to work:
void main(string args[])
{
auto f = File("test.txt", "w");
f.writeln("Hello, Worlds!");
}
I'm using the dmd compiler on windows.
If you are using D2, you need to import std.stdio;
:
import std.stdio;
void main(string args[])
{
auto f = File("test.txt", "w");
f.writeln("Hello, Worlds!");
}
If you are using D1, the File
class is in std.stream
, and the API is slightly different:
import std.stream;
void main() {
auto f = new File("test.txt", FileMode.Out);
f.writeLine("Hello, Worlds!");
}