20120113

Program in C++ to learn to reverse a strings in Cpp

//========================
//Program in Cpp to learn to reverse a strings in Cpp, strrevcpp3.cpp
//========================

#include<iostream>
using namespace std;
int main()
{
char orgstr[]="manoj";
cout<<"\n original string is:\n\n"<<orgstr<<"\n";

int i,j,c;
for(i=0,j=strlen(orgstr)-1;i<j;i++,j--)
{
c=orgstr[i];
orgstr[i]=orgstr[j];
orgstr[j]=c;
}
cout<<"\n Reversed String is: \n\n"<<orgstr<<"\n";
return 0;
}
Previous                             Home                               Next

1 comment:

  1. How to reverse a string in C++ / CPP
    How to reverse a string in C++ / CPP
    How to reverse a string in C++ / CPP
    How to reverse a string in C++ / CPP
    How to reverse a string in C++ / CPP

    ReplyDelete