Page 1 of 1

Convert to struct

Posted: Sun Aug 19, 2007 12:23 pm
by xarnze
when i read data from the floppy disk i set a pointer to the memory location where it has been stored, how can i then read this data into a structure for my BPB as i keep getting either:
conversion to non scalar type requested
or
incompatible type in assignment

This is my structure:

Code: Select all

typedef struct BOOT{
	unsigned char jmp[3];
	unsigned char OEM[7];
	unsigned short bps;
	unsigned char cluster_size;
	unsigned short reserved;
	unsigned char fats;
	unsigned short dir_entrys;//
	unsigned short total_sectors;//
	unsigned char mds;
	unsigned short secfat;
	unsigned short sectrack;
	unsigned short sides;
	unsigned char hide[4];
	unsigned char large[4];
	unsigned char drive;
	unsigned char flags;
	unsigned char sig;
	unsigned char volume_ID[4];
	unsigned char volume_label[11];
	unsigned char system_identifier[8];
	unsigned char bootstrap[449];
	unsigned short boot_sig;
}__attribute__ ((packed)) boot;

Posted: Sun Aug 19, 2007 5:33 pm
by frank
You should try the following

Code: Select all

boot *bpb = (boot *)pointer_to_floppy_data;
// then you can access  the members with
bpb->bps;

Posted: Mon Aug 20, 2007 3:49 am
by xarnze
Thank you.