Need some help with this

Started by
2 comments, last by matt_j 21 years, 3 months ago
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

Advertisement
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]
Member of the Unban Mindwipe Society (UMWS)
Yes. But the second time I call it, it crashes. The data reads fine the first time.

Sub-Terra
Software - High quality free games and applications


matt_j@shaw.ca

subterrasoft@hotmail.com

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.

This topic is closed to new replies.

Advertisement