Answers for "reverse a string in c++ stl"

C++
1

string reverse stl

int main() { 
    string str = "foobarbaz";
    reverse(str.begin(), str.end()); 
    cout << str; // prints "zabraboof"
    return 0; 
}
Posted by: Guest on March-13-2021
-1

reverse string c++

#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
string str;
  getline(cin,str);
  reverse(str.begin(),str.end());
  cout<<str;
}
Posted by: Guest on July-06-2021

Browse Popular Code Answers by Language