reverse word C++
#include "iostream"
#include "string"
using namespace std;
int main()
{
string first;
//with spaces this will not work
cout<<"Enter the first word";
cin>>first;
const char * cs = first.c_str ();
while(*cs)
{
cs++;
}
cs--;
while(*cs)
{
cout<<(*cs);
cs--;
}
cin>>first;
}
#include "string"
using namespace std;
int main()
{
string first;
//with spaces this will not work
cout<<"Enter the first word";
cin>>first;
const char * cs = first.c_str ();
while(*cs)
{
cs++;
}
cs--;
while(*cs)
{
cout<<(*cs);
cs--;
}
cin>>first;
}
Comments
Post a Comment