Sub-Terra
Software - High quality free games and applications
matt_j@shaw.ca
subterrasoft@hotmail.com
Need some help with this
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);
}
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]
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 BillAny pointer can be implicitely converted to void*, it''s not an error.
Strange, MSVC doesn''t catch the error of casting a void** to a void*
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement