Answers for "how to reverse a string without using built in function in c++"

C++
2

reverse string efficient in cpp without using function

#include <iostream>
using namespace std;
int main()
{
    char str[] = "Reverseme";
    char reverse[50];
    int i=-1;
    int j=0;
         /*Count the length, until it each at the end of string.*/ 
          while(str[++i]!='');
           while(i>=0)
                    reverse[j++]=str[--i];
            reverse[j]='';
      cout<<"Reverse of  a string is"<< reverse;
      return 0;
}
Posted by: Guest on September-16-2020
-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

Code answers related to "how to reverse a string without using built in function in c++"

Browse Popular Code Answers by Language