I am a beginner & I need to implement this program which states that I have to reverse whatever is given in input via pointers...
For Example:
i) Input: This is reverse order program
Output: program order reverse is This
ii) Input: This is exercise eight
Output: eight exercise is This
I made it a little bit, but it outputs to "is input" if i input "The input is" string.
#include<iostream>
using namespace std;
int main()
{
char sentence[80]={0};
cout<<"Input the string: ";
cin.getline(sentence,80,'\n');
int length=strlen(sentence);
int check=0;
for(int i=length; i>0; i--)
{
if(sentence[i]!=' ')
{
check++;
}
else
{
for(int j=i; j<(check+i); j++)
cout<<sentence[j+1];
cout<<" ";
check=0;
}
}
return 0;
}
Thanks!