/* Sentence Reverser, prog. 3 from CS 270, using CC8 with Ace C libraries *//* by Mark Miller 2/4/91 */#define NULL 1536struct nrec$(  char data;  struct nrec *next;$);push(stack, p)  struct nrec **stack, *p;$(  p->next = *stack;  *stack = p;$) /* push */struct nrec *pop(stack)  struct nrec **stack;$(  struct nrec *p;  p = *stack;  *stack = (*stack)->next;  return p;$) /* pop */readsent(sentstack, rdone)  struct nrec **sentstack;  int *rdone;$(  char ch;  struct nrec *p;  *sentstack = NULL;  poke(764,255);  while((ch = getchar()) != '\n')    if(ch != '*')    $(      p = (struct nrec *) malloc(sizeof(struct nrec));      p->data = ch;      push(sentstack, p);    $) /* if */    else      *rdone = 1;$) /* readsent */esrever(sentstack, wordstack)  struct nrec **sentstack, **wordstack;$(  struct nrec *chptr;  char punct;  *wordstack = NULL;  chptr = pop(sentstack);  /* punctuation is first element on stack */  punct = chptr->data;  free(chptr);  do  $(    /* get char to push on 2nd stack */    chptr = pop(sentstack);    if((chptr->data != ' ') && (*sentstack != NULL))      push(wordstack, chptr);    else    $(      /* if stack is not empty, get rid of char */      if(*sentstack == NULL)      /* if stack is empty, print char */        printf("%c", chptr->data);      free(chptr);      do      $(        /* get char from stack */        chptr = pop(wordstack);        printf("%c", chptr->data);        free(chptr);      $) while(*wordstack != NULL);      /* if stack is not empty, print space */      if(*sentstack != NULL)        printf(" ");      *wordstack = NULL;    $) /* else */  $) while(*sentstack != NULL);  printf("%c\n", punct);$) /* esrever */main()$(  struct nrec *sentstack, *wordstack;  int done;  almreset();  done = 0;  while(!done)  $(    printf("Type in sentence.  Use * to quit program\n");    readsent(&sentstack, &done);    if(!done)    $(      printf("reversed:\n");      esrever(&sentstack, &wordstack);      printf("\n");    $) /* if */  $) /* while */$)