|
-
June 10th, 2009, 10:56 PM
#14
Re: Access Violation Error Help
 Originally Posted by Shadow_Govt
Your right! Thanks for pointing that out.
I made edits to my last post. If you write a function for resizing the string, and use that to get you new strings, that would, at the very least, neaten the code up somewhat so that it becomes easier to spot problems (and harder to make mistakes).
Note that the function takes care of everything -- allocation and deallocation -- this removes a lot of the "naked" calls to "delete[]" and "new char[]" all over your code. Remember that I did not test that function. If there is a bug, you will have to focus on it. But at least it moves the focus to a central location, and not all over your code.
I would also suggest you write a similar function for resizing the arrays of pet info. Something like this:
Code:
char **ResizePetInfo(char**& petInfo, unsigned int newSize)
{ ///
function here to do all of the resizing of the petInfo array
}
//...
petName = ResizePetInfo(petName, animalcount);
//...
Then this eliminates the naked new/delete calls you're making to resize the pet information. I am not going to write it, as it's your assignment.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; June 10th, 2009 at 11:02 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|