reverse string without using strrev function