Jump to content
  • Advertisement

Archived

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

Coluna

fucking fread( );

This topic is 5463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all; I''m having a very strange problem here... Here is some part of the code: ... profiles = new cPROFILE[number_of_profiles]; fread(profiles,1,sizeof(cPROFILE)*number_of_profiles,file); delete []profiles; ... Of course the line "delete []profiles;" is not there, but if I put it there it generates an Acess Violation Error...but when i take off the fread line, the error disappears. May it be a compiler error? Thanx all

Share this post


Link to post
Share on other sites
Advertisement
i am almost pretty sure that your problem is in the call to fread try
fread (profiles,sizeof(cPROFILE),number_of_profiles,file);

hope that helps

Share this post


Link to post
Share on other sites
I''ve already tried using
fread(profiles,sizeof(cPROFILE),number_of_profiles,file);
but it didn''t solve my problem...

Share this post


Link to post
Share on other sites
shouldnt it be:
fread(&profiles[0], sizeof(cPROFILE)*number_of_profiles, 1, file);
?

Share this post


Link to post
Share on other sites
the only thing the two separate parameters do is if it reaches the end of file early, it reads the last whole structure before the end, but internally it just multiplies and reads. 1, x works fine, i use that all the time.

Share this post


Link to post
Share on other sites
There is no pointers inside cPROFILE....and even using &profiles[0] (i used it before), it doesn''t work....when i inspect profiles (with quickwatch), it is allocated and with the correct values...so the fread() is working, as well as new()...i think i''ll try to copy this part in other application and see the results...

Share this post


Link to post
Share on other sites
heh, well:

(profiles == &profiles[0]) == true

edit: forgot one 's'

[edited by - angry on July 5, 2003 2:16:25 AM]

Share this post


Link to post
Share on other sites
Is that the exact code? Is there anything that goes on between the call to fread and the call to delete?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!