Load entire file, as a char array.

Neia Neutuladh neia at ikeran.org
Mon Sep 3 03:19:39 UTC 2018


On Monday, 3 September 2018 at 03:04:57 UTC, Chris Katko wrote:
> This should be simple? All I want to do is load an entire file, 
> and access individual bytes. The entire thing. I don't want to 
> have know the file size before hand, or "guess" and have a 
> "maximum size" buffer.
>
> So far, all google searches for "dlang binary file read" end up 
> not working for me.
>
> Thank you.

http://dpldocs.info/experimental-docs/std.file.read.1.html

import std.file : read;
auto bytes = read("filename");

This gives you a void[], which you can cast to ubyte[] or char[] 
or whatever you need.


More information about the Digitalmars-d-learn mailing list