#include
int main(void)
{
int i,j;
int wordstart = -1;
int wordend = -1;
char words[]= \"this is a test\";
char temp;
// Reverse each word
#include
#include
using namespace std;
char* stringrev(char s[], int len)
{
char *s1 = (char*)malloc(len+1);
int i=0;
while (len>0)
{
s1[i++] = s[--len];
}
s1[i++] = '\0';
return s1;
}
void sentrev(char s[], int len)
{
int i=0; int j=0;
char *r = (char*)malloc(len+1);
while(1)
{
if(s[j] == ' ' || s[j] == '\0')
{
r = stringrev(s+i, j-i);
i = j+1;
cout<
The above code snap reverse the sentence, using char *r and printing cout<