Load entire file, as a char array.

bauss jj_1337 at live.dk
Mon Sep 3 06:25:23 UTC 2018


On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh wrote:
> 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.

Or he could do readText() which returns a string, which in turn 
will give a proper char array when casted.


More information about the Digitalmars-d-learn mailing list