Archived

This topic is now archived and is closed to further replies.

matt_j

Need some help with this

Recommended Posts

What is wrong with this. It crashes the program. I want to read data into a structure or variable: assume: a FILE is open called "data" a "datafile" class exists as df -------------------- BITMAPFILEHEADER df; df->readdat(&bminfo,sizeof(BITMAPFILEHEADER)); ----------------------- void datafile::readdat(void *buf, unsigned int len){ fread(&buf,len,1,data); }

Sub-Terra Software - High quality free games and applications
matt_j@shaw.ca
subterrasoft@hotmail.com

Share this post


Link to post
Share on other sites

void datafile::readdat(void *buf, unsigned int len){
fread(&buf,len,1,data);
}

shoule be

void datafile::readdat(void *buf, unsigned int len){
fread(buf,len,1,data);
}

(Note the lack of the &)

Edit: Just tested it. Strange, MSVC doesn't catch the error of casting a void** to a void* ...




[edited by - Evil Bill on December 24, 2002 3:01:10 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Evil Bill
Strange, MSVC doesn''t catch the error of casting a void** to a void*
Any pointer can be implicitely converted to void*, it''s not an error.

Share this post


Link to post
Share on other sites