Convert to struct

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
xarnze
Posts: 19
Joined: Thu Nov 02, 2006 4:45 pm
Location: United Kingdom
Contact:

Convert to struct

Post 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;
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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;
xarnze
Posts: 19
Joined: Thu Nov 02, 2006 4:45 pm
Location: United Kingdom
Contact:

Post by xarnze »

Thank you.
Post Reply