#include<iostream>
using namespace std;
void Reverse_Word(char *start,char *end)
{
char tmp;
while(start<end)
{
tmp=*start;
*start=*end;
*end=tmp;
start++;
end--;
}
}
void Reverse_String(char *str)
{
char *start,*end;
start=end=str;
while(*end!='\0')
end++;
end--;
Reverse_Word(start,end);
char *substr=start;
while(start<=end+1)
{
if(*start==' '||*start=='\0')
{
char *temp=start-1;
Reverse_Word(substr,temp);
while(*++start==' ');
substr=start;
continue;
}
else
start++;
}
}
int main()
{
char a[]="I am a student";
cout<<a<<endl;
Reverse_String(a);
cout<<a<<endl;
return 0;
}