[your code here]
qjnr
fakemail at mailinator.com
Tue Jan 29 21:13:16 UTC 2019
/* This is a very basic implementation of cat in the D
programming language.
For more info about the D programming language, visit
https://dlang.org .
Copyright (c) 2018 qjnr */
import std.stdio : readln, write, writef;
import std.file : readText, exists;
void main(string[] args)
{
if (args.length is 2)
{
string fname = args[1];
if (!exists(fname))
{
writef("cat: %s: No such file or directory", fname);
}
else
{
string content = readText(fname);
write(content);
}
}
else
{
string line;
while ((line = readln()) !is null)
{
write(line);
}
}
}
More information about the Digitalmars-d
mailing list