Created
July 4, 2022 11:43
-
-
Save 2439905184/8eb02945dfabb49ee10bf1c6d46bb55e to your computer and use it in GitHub Desktop.
在D语言中读写二进制文件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```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