CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 18

Threaded View

  1. #14
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Access Violation Error Help

    Quote Originally Posted by Shadow_Govt View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured