Reverse a string in c++ without using libraries