/* This is a program that reverses the lines of stdin using a doubly-linked list */ #include #include "dlist.h" main() { char s[1000]; char *news; Dlist d; Dlist tmp; d = make_dl(); while (gets(s) != NULL) { news = (char *) malloc(strlen(s)+1); strcpy(news, s); dl_insert_b(d, news); } for (tmp = dl_last(d); tmp != dl_nil(d); tmp = dl_prev(tmp)) { printf("%s\n", tmp->val); } }