| | |
Heap Corruption??!! Help!!!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 25
Reputation:
Solved Threads: 0
Hello, i'm doing my home work, it's about managing a library, i created 4 trees as required in my assignment.
The problem arises with RemoveCategory function. I just don't know why but each time i try to remove books in order like this (the names of the books are in "File.txt")
_ Remove Tobie Lolness
_ Remove 1 ve
_ Remove No family
--> Problem arises here, saying that there is a heap corruption. I tried debugging, and when the program get to the line delete [] p->pCategory , it says "heap corruption".
I'm new to this, i don't understand what it's trying to say and how to solve this crazy problem, because when the order is different, the program still runs smoothly ~X(
Help me please ^
^ My code is attatched below
The problem arises with RemoveCategory function. I just don't know why but each time i try to remove books in order like this (the names of the books are in "File.txt")
_ Remove Tobie Lolness
_ Remove 1 ve
_ Remove No family
--> Problem arises here, saying that there is a heap corruption. I tried debugging, and when the program get to the line delete [] p->pCategory , it says "heap corruption".
I'm new to this, i don't understand what it's trying to say and how to solve this crazy problem, because when the order is different, the program still runs smoothly ~X(
Help me please ^
^ My code is attatched below Last edited by kalodakilla; Aug 26th, 2008 at 8:47 am.
•
•
Join Date: Aug 2008
Posts: 206
Reputation:
Solved Threads: 31
That code is too big for anyone to bother looking at. Try eliminating code to produce a small but complete code sample that exhibits your problem. If you get lucky, you will find/fix the problem in the process of producing that small code sample. If not, people will be more willing and able to help.
Odds are, the cause is an invalid operation on a pointer in code executed before the line where the "heap corruption" is reported. Invalid operations with a pointer include dereferencing a pointer that doesn't actually point at anything valid (eg a NULL, or an uninitialised pointer) or falling off the end of an array (eg accessing element 10 in a 5-element array).
Odds are, the cause is an invalid operation on a pointer in code executed before the line where the "heap corruption" is reported. Invalid operations with a pointer include dereferencing a pointer that doesn't actually point at anything valid (eg a NULL, or an uninitialised pointer) or falling off the end of an array (eg accessing element 10 in a 5-element array).
•
•
Join Date: Apr 2008
Posts: 25
Reputation:
Solved Threads: 0
Thanks for you reply, i have tried my best to delete other functions, i just kept the add and remove function.
Please just look at the remove functions, especially the RemoveCategory function, all of the problems just arise there. Can you just remove the books in the order i mention and do you meet the same error like i do
, plz 
I consider checking if i delete any NULL pointer, but still, i'm not deleting any NULL things, i just don't know why the dynamic array is right there and i can't delete it ~X(
Please just look at the remove functions, especially the RemoveCategory function, all of the problems just arise there. Can you just remove the books in the order i mention and do you meet the same error like i do
, plz 
I consider checking if i delete any NULL pointer, but still, i'm not deleting any NULL things, i just don't know why the dynamic array is right there and i can't delete it ~X(
![]() |
Similar Threads
- HEAP Corruption Error (C++)
- Strings this time (C++)
- Call Stack (C++)
- realloc malloc and Heap problem. (C++)
- Merge Sort on a Array-Based List (C++)
Other Threads in the C++ Forum
- Previous Thread: Shared Memory Object Access
- Next Thread: struct problem
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg simple sorting string strings template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





