#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>

char *Scramble(char *str)
{
  char *pTmp, *pWord;
  int size, c;
  
  pTmp = pWord = str;
  do
  {
    pTmp = strchr(pTmp, ' ');
    if(pTmp)
      size = (pTmp - pWord);
    else
    {
      size = strlen(pWord);
      pTmp = pWord + size;
    }
    
    for(c = 0; c < (size / 2); c++)
    {
      char ch = *(pTmp - c - 1);
      *(pTmp - c - 1) = *(pWord + c);
      *(pWord + c) = ch;
    }

    while(isspace(*pTmp)) pTmp++;
    
    pWord = pTmp;
  } while(size);  
  
  return str;
}

void main()
{
  char str[256];
  printf("Str: ");
  gets(str);
  printf(Scramble(str));
  getch();
}
1