file i/o [Archive] - C Board

PDA

View Full Version : file i/o


confuted
07-17-2002, 09:39 PM
I'm think I am having some problems with this, and I'm wondering if it's because I am trying to do something that can't be done. What it is is that I have saved data in a binary file, which I wrote by using fwrite like this...

fwrite(&anarrayofstructs, sizeof(thestuct), numberofelementsinthearray, filepointer);

I am trying to read it in the same way, except with fread...is this not possible, or is my error somewhere else? Or is there maybe something that I don't know?

no-one
07-18-2002, 01:14 PM
try this

// set the packing alignment to 1 byte
#pragma pack(1)

//your file structs go here

// set the packing alignment to default
#pragma pack(0)