One of  good question can be asked about string is How to Reverse String ? 

You can do in many ways but I am going to show you , the one of the best  way to do this using sstream , which is more convenient and in short time.

#include <iostream>
#include <sstream>
using namespace std;
string rev (string s);
int main() {
string st = "I love CODING !!!"; 
stringstream ss;
 string s1;
 ss << st; 
 s1 = rev(s1);
 cout << s1 << " ";
 return 0; 

string rev (string s) { 
char temp;
 unsigned long long int i=0, lli = s.length()-1; 
while(i<lli) { 
temp = s[i]; 
s[i] = s[lli];
 s[lli] =temp;
 i++; lli--; 
return s;
Hope you learnt something , stay tune for more examples and interesting facts about c++.

Have something to add Reverse String in c++ ?? share it in comments .

Follow us on Facebook, Google Plus and Twitter.