You've most probably corrupted the heap earlier in your program by writing beyond the end of the allocated block.
Depending on what environment your program runs in, there are debug tools that can help find the problem. It's a common problem in C and C++.
Last edited on
Thanks
that makes sense I think this is it.