Solution for reversing c style string