A little question

How to flip over the value in string E.g String a = "Hello" //some code Output olleh

2/26/2020 3:10:09 PM


3 Answers

New Answer


You can use string reverse iterator to generate a reversed version, as follows: std::string str {"Hello World"}; std::string reversed {str.crbegin(), str.crend()}; std::cout << reversed;


Loop over the string from back to front printing each char.