write struct as raw data to file

Paul phshaffer at gmail.com
Sun Sep 26 15:09:38 UTC 2021


I'm building a binary file.  I can write my 'short[] myArray' 
directly to the file using: File f = File( "myFile.wav", "wb" ); 
f.rawWrite(myArray); It doesn't write any array formatting stuff 
(i.e. '[ ,  , ]'); it just moves the data into myFile like I want.

I can't seem to do this with myStruct? myStruct is just a 
declaration and initialization of a dozen atomic types (e.g uint 
WAVE_Id = 0x45_56_41_57).  When I issue f.rawWrite(myStruct), it 
writes "myStruct(...,...,etc. ) instead of just writing the data.

Is there way to write the myStruct data to the file in a single 
statement...or two?

Thanks for any assistance.



More information about the Digitalmars-d-learn mailing list