I was wondering that! Maybe OP intended to post different code.

As has been said the code posted will work on C style strings. To modify it to work for integer arrays you'll need to consider that...