How can I serialize a struct into a file in the style of C?
solidstate1991 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 22 19:07:45 PDT 2017
On Saturday, 22 July 2017 at 02:22:53 UTC, Mike Parker wrote:
>
> I should add, though, that you're better off using either
> std.stdio.File or std.file. Use the former if you need to make
> multiple reads/writes to a file, the latter if you can pull it
> in or push it out all in one go. They take arrays as arguments,
> so if you have something like Data[], you can pass it directly
> to the appropriate functions. To write a single instance,
> you'll have to take the pointer and slice it. Either way, it's
> less code, less error prone, and more idiomatic than using the
> C API.
Well, it seems the toStringz() function adds a few garbage
characters to the end of the filename, I might look into a way to
read the data with Phobos instead of the C API.
More information about the Digitalmars-d-learn
mailing list