Check out example codes for "reverse string in c++ without using function". It will help you in understanding the concepts better.

Code Example 1

// A simple C++ program to reverse string using constructor  
#include <bits/stdc++.h>  
using namespace std;  
int main(){ 
  
    string str = "GeeksforGeeks"; 
  
    //Use of reverse iterators 
    string rev = string(str.rbegin(),str.rend()); 
  
    cout<<rev<<endl;  
    return 0; 
}

Code Example 2

// A Simple C++ program to reverse a string 
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to reverse a string 
void reverseStr(string& str) 
{ 
    int n = str.length(); 
  
    // Swap character starting from two 
    // corners 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
} 
  
// Driver program 
int main() 
{ 
    string str = "geeksforgeeks"; 
    reverseStr(str); 
    cout << str; 
    return 0; 
}

Code Example 3

// A quickly written program for reversing a string 
// using reverse() 
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{ 
    string str = "geeksforgeeks"; 
  
    // Reverse str[begin..end] 
    reverse(str.begin(), str.end()); 
  
    cout << str; 
    return 0; 
}

Learn ReactJs, React Native from akashmittal.com