#include
#include
using namespace std;
void reverse(char* sentence)
{
int index = strlen(sentence) - 1;
char last = \'\\0\';
Here I used splitting (tokenizing) sentence into words and then use that for reverse printing. Hope this help-
#include
#include
#include
#include
using namespace std;
vector split(char* str, char delimiter=' ')
{
vector result;
do
{
char* begin =str;
while(*str != delimiter && *str)
str++;
result.push_back(string(begin, str));
}while(0 != *str++);
return result;
}
int main()
{
string str;
vector tempStr;
cout<<"Enter The String: ";
getline(cin, str);
cout<=0; i--) str+=tempStr.at(i)+" ";
//cout<