Feb 8, 2017 at 11:34am UTC
is there any function to reverse my string???
Feb 8, 2017 at 12:09pm UTC
OP: bear in mind that std::reverse() works in place, so the original string will be lost unless you make a copy of it first (or reverse() the reversed string!)
Last edited on Feb 8, 2017 at 12:10pm UTC
Feb 8, 2017 at 12:58pm UTC
if you want to understand HOW to do it, rather than use the built in..
you can do it a number of ways.
one way is to go to the end of the string and iterate over it backwards, copying into a new string.
you can also grab the first and last character, swap, second and next to last, swap, ... in a loop until your pointers cross or equal each other.
And if you want to do it fast, you can use the cpu provided byte swapper (assembly) designed for the endian integer problem :)
Last edited on Feb 8, 2017 at 12:59pm UTC