Coders Packet

Reverse Of String Using STL In C++

By Aditi Mishra

This project performs string reverse using STL in C++. The string is accepted, the reverse operation is done, and characters are pushed back in the string. The resultant output is produced.

The string is a collection of characters enclosed within double quotes. Reversing simply means that we are changing the order of letters or characters in an array of strings.

Reversing helps us in many ways. One way is that reversing allows us to access the characters stored in the last which are not accepted during the execution from the starting. It allows us in searching and sorting purposes also from the ending side of the string.

In my program, an input of the string is taken in c, and then its size is calculated in l and then using STL(Standard Template Library), and using a reverse function in c++ language, the string is reversed and the final reversed string is displayed in the output.



using namespace std; 
int main() { 
string c; 
cout<<"\nEnter the string:-> "; 
vector p; 
int l=c.length(); 
for(int i=0;i<l;i++) { 
char ch=c[i]; 
p.push_back(ch); //putting the values in ch 
cout<<"\nThe string before reversing:-> "; 
for(int i=0;i<p.size();i++) { 
cout<<"\n"; reverse(p.begin(),p.end()); 
cout<<"\nThe resultant reversed string:-> "; 
for(int i=0;i<p.size();i++) { 
return 0; 



INPUT-Enter the string:-> Aditi

OUTPUT- The string before reversing:-> Aditi

                 The resultant reversed string:-> itidA


INPUT- Enter the string:-> Shreya

OUTPUT- The string before reversing:-> Shreya

                 The resultant reversed string:-> ayerhS

Download project

Reviews Report

Submitted by Aditi Mishra (aditi1310)

Download packets of source code on Coders Packet