Jump to content
  • Advertisement
Sign in to follow this  

delete[] word array = error

This topic is 4957 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, I tried the search but that gave a odbc error so i'm sorry to post such a noob question :$. At the delete[] data; I get the next error: Debug Error! DAMAGE: after Normal block(#76 at 0x(bignumber) Can somebody tell me what i'm doing wrong ? If i replace the WORD with a int and the fscanf %u with %i everything works fine.
WORD *data = new WORD[amount];

for(i=0;i<Header.iIndices;i++)
{
  fscanf(file, "%u", &data);
}

delete[] data;

Share this post


Link to post
Share on other sites
Advertisement
My best guess is that you are writing out of bounds. Are you sure 'Header.iIndices' is smaller or equal to 'amount'

Share this post


Link to post
Share on other sites
Quote:
Original post by smart_idiot
A word is 2 bytes, and an unsigned integer is 4 bytes (in this case), so fscanf writes 2 bytes past the end of the array.


I knew that a word is 2 bytes and a int 4 but why does fscanf write 2 bytes past the end of the array ?

Yes both values are the same. I get the same error when i hardcode the values.

Share this post


Link to post
Share on other sites
Ok i replaced the u with a hu and now i get no error's. But however the other problem now is that the data in my array makes totally no sense :s. Instead of 0 2 it's now 5232 or something like that.
Is that because i use a text file instead of a binary file ? If i read the data as a %i i get the correct data. Can somebody please give me a push into the right direction ?

ps. strange i looked in my book and in the msdn help file but i couldn't find a h for fscanf.

[Edited by - twan on October 23, 2004 10:14:41 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!