/* Example 22.3 Print list in reverse order using recursion Author: Peter Brusilovsky */ #include "IntLL.h" #include void printReverse(NODE *l); void printList(NODE *l); void main(){ LIST *mylist; int c; mylist = createList(); while((c = getchar()) != EOF) addNode(mylist, c); printf("\n"); printList(mylist->head); printf("\n"); printReverse(mylist->head); printf("\n"); destroyList(mylist); } void printList(NODE *l) { /* nothing to do with an empty list */ if(l == NULL) return; /* for non empy list print reversed the rest of it and then the first node */ printf("%c ", l->data); printList(l->link); return; } void printReverse(NODE *l) { /* nothing to do with an empty list */ if(l == NULL) return; /* for non empy list print reversed the rest of it and then the first node */ printReverse(l->link); printf("%c ", l->data); return; }