Skip to content

Instantly share code, notes, and snippets.

@2439905184
Created July 4, 2022 11:43
Show Gist options
  • Save 2439905184/8eb02945dfabb49ee10bf1c6d46bb55e to your computer and use it in GitHub Desktop.
Save 2439905184/8eb02945dfabb49ee10bf1c6d46bb55e to your computer and use it in GitHub Desktop.
在D语言中读写二进制文件
```c++
import std.stdio;
import std.file;
void main()
{
//写文件
byte[] buffer1 = [1,2,3,4,5];
File f = File("a.txt","w");
f.rawWrite(buffer);
f.close();
//读文件
byte[5] buffer2;
File f2 = File("a.txt","r");
f.rawRead(buffer2);
//输出读取的内容
writeln(buffer2);
f2.close();
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment