You are accessing the array out of bounds. (last iteration of the loop)
Also there is no need for the extra level of indirection. http://www.cplusplus.com/doc/tutorial/arrays/ (arrays as parameters)
Side note: It should be an easier way for posting code. Especially considering that this is a programming forum.