跳转到内容


D语言读写文件的操作


  • 您无法回复此主题
No replies to this topic

#1 冰力

    Administrator

  • 总版主
  • 862 帖子数:
  • Location上海

发表于 2012/02/19 01:10:35

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();
}

在网上看到的一段代码,分享了。





目前查看此主题的用户: 1 位

0 位会员, 1 位游客, 0 位隐身会员