Jump to content

File input/output: Difference between revisions

Line 714:
 
=={{header|D}}==
{{libheader|Phobos}}
{{works with|D|2}}
<lang d>import std.file: copy;
Line 719 ⟶ 720:
void main() {
copy("input.txt", "output.txt");
}</lang>
 
via an intermediate variable:
<lang d>import std.stdio;
 
void main() {
auto from = File("input.txt", "rb");
auto to = File("output.txt", "wb");
 
byte buf[1024*1024];
for (;;) {
auto rdBuf = from.rawRead (buf);
if (rdBuf.length == 0) break;
to.rawWrite(rdBuf);
}
from.close();
to.close();
}</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.