There is no immediate error with the code you presented (aside from the semicolon you're missing when you call show). If you're having issues, it's not directly related to the code that you have presented us. And as fun2code pointed out, you need to share more of your code before we're going to be able to effectively debug it for you. Also, you haven't specified exactly what happens. The program stops working isn't enough information. Does it freeze? Does it crash? What happens immediately before doing the above?
There is too many unknowns here and we're not fortune tellers and can't see your code unless you share it with us. If you want us to take guesses, fine, but most of us won't attempt to do that. I'm assuming your program is crashing and it's due to a memory access violation due to going out of bounds of your array. With that being said, you need to modify certain loops etc. so that your array, and when accessing values of said array, don't exceed the declared size of it. Your function, or something else in your code is to blame, but not what you've shown us.