0

What symbol/key word should i use to have a reverse output? Like garbage-> egabrag

14th Sep 2021, 12:04 PM
Lenard Marinduque
Lenard Marinduque - avatar
2 Answers
+ 3
There is a built-in reverse() function Defined in algorithm header file. You have to give string begin and string end As arguments to this function. For example #include <algorithm> #include<iostream> #include<string> using namespace std; int main() {     string s = "Reverse me";     reverse(s.begin(), s.end());     cout<<s;     return 0; } OUTPUT: em esreveR
14th Sep 2021, 12:40 PM
Yugal Kishore
+ 2
If you are working with std::string class then you can use std::reverse() defined in <algorithm> header to reverse it. If you are working with C style strings then I don't think there is a factory function to do this, and you have to do it manually. https://en.cppreference.com/w/cpp/algorithm/reverse
14th Sep 2021, 12:41 PM
Arsenic
Arsenic - avatar