using fwrite() to write a struct to a file

后端 未结 3 1526
深忆病人
深忆病人 2021-01-18 08:54

I have the following program:

#include 
#include 
#include 

#define MAXLEN 100

typedef struct {int key; char         


        
3条回答
  •  感动是毒
    2021-01-18 09:49

    I have also had same kind of problem while reading BIOS parameter block structure from a floppy disk image. I resolved it by using #pragma pack(1) directive. Sample code is below:

    #pragma pack(1)
    struct bpb
    {
        unsigned char jmpinstruction[3];
        unsigned char oem[8];
        short bytespersector;
        ....
    };
    #pragma pack()
    

提交回复
热议问题