http://pastebin.com/esxAR3wY
This is my source code here...It is simply too big and ugly to fit in here, so I used this site..
If anyone can paste the code into his compiler and help me I will be grateful.
Everything works except for the "addEntry" function (and I am guessing "resizeArrayCopy" function too)..so if you are willing to help me, look there.
My problem basically is:
When I set the buffer size to 4, then load a file that has 4 entries, then I try to add a new entry from the menu, entry number FIVE just shows up blank after that. Entries after this entry are perfectly fine tho.
When I load a file that has less than 4 elements, then fill up the buffer with my data, the FIFTH element shows some strange characters, and (I think, not 100% sure) that in this case, entries six and onward work perfectly. I have been trying to catch the problem this entire day, and couldn't. If you are willing to help me, you definately need to compile the code and run the program in order to see for yourselves what exactly is wrong, since the code is very ugly written and it is (quite) big..
PS: compiling with codeblocks
cooh
0
Newbie Poster
Recommended Answers
Jump to PostThere are several problems with that program. There may be other problems that I have not yet found.
- addEntry() -- the first parameter needs to be passed by reference, not by value (See line below). That is because the array is reallocated at the start of the function, and that …
Jump to PostEntry* resizeArrayCopy(Entry*& fpBuffer, const size_t resizeStep, size_t &bufferSize) { Entry* pNewBuffer = new Entry[bufferSize + resizeStep]; if(pNewBuffer == NULL) { return NULL; }
In the above, new does not return NULL, instead it throws an exception, If you want to test for NULL you have to …
All 5 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
cooh
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
cooh
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.