Answers for "how to reverse a string using 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

How to reverse a string in c++ using reverse function

#include <iostream>
//The library below must be included for the reverse function to work
#include<bits/stdc++.h> 
using namespace std;

int main() {
  
  string greeting = "Hello";
  //Note that it takes the iterators to the start and end of the string as arguments
  reverse(greeting.begin(),greeting.end());
  cout<<greeting<<endl;
}
Posted by: Guest on August-20-2021

Code answers related to "how to reverse a string using stl"

Browse Popular Code Answers by Language