Since you gave no description of the error, I am making an educated guess here...
You are taking a string that is 10 bytes long and indexing (in your for loop) positions 11-2. Remember that computers count starting with 0, where humans start with 1. So str[10] = position 11. Try changing your for loop as follows: for (int num=9; num>=0; num--)