| dragoonts (2) | |
|
Hello everyone, I was making a relatively simple program to index a .txt file for class, and I got the following error trying to run it. *** glibc detected *** ./index: free(): invalid pointer: 0x000000000060b600 *** I'm unsure of what could be causing the problem. I am primarily using vectors and a struct (with a string, int and array as fields). I'd rather not post the source just because it has to deal with school, but if someone would like to help me 1-on-1, I would gladly show them. Thank you very much. I compiled using g++ and a makefile (both are standard in the course I am taking, and the makefile was given to us by our prof, so it is correctly built). | |
|
Last edited on
|
|
| Peter87 (3691) | |
Are you using delete somewhere? Make sure the pointer is valid and that it was actually created with new.
| |
|
|
|
| dragoonts (2) | |
|
I am not using delete anywhere in my code, neither am I creating pointers explicitly. Essentially, my code works like: -Read line of .txt doc, remove punctuation, separate words (working fine) -Create a word object for each word -For each word, check if it's already in the vector. If yes, update the fields(occurences and pages array), if no, insert it so the vector remains alphabetically sorted. -Print the words, their occurrences, and the pages they occur to another .txt file EDIT: I just fixed it. There was an error in a for loop, simple as that. | |
|
Last edited on
|
|