import std.stream;
import std.stdio;
void main () {
File file = new File ;
File OutFile = new File;
try {
file.open("1.srt",FileMode.In);
OutFile.open("out.srt", FileMode.Out);
while(!file.eof()) {
char[] str=file.readLine();
OutFile.writeLine(str);
//printf("%.*s\n",file.readLine());
}
}
catch (Exception x) {
writefln("Datei kann nicht geoeffnet werden ");
throw x;
}
OutFile.close();
file.close();
}
本文提供了一个使用D语言进行文件复制的简单示例代码。该程序通过打开源文件和目标文件,逐行读取并写入的方式实现文件内容的复制。此过程展示了D语言中文件操作的基本用法。
223

被折叠的 条评论
为什么被折叠?



