#include #include struct lnode { char data; struct lnode *next; }; int listlength(struct lnode *list); struct lnode *makelist(char *s); void printlist(struct lnode *list); void main(void) { struct lnode *list; char t[] = "Why worry?"; list = makelist(t); printlist(list); printf("\n"); printf("%d\n", listlength(list)); } int listlength(struct lnode *list) { if (list == NULL) return 0; return listlength(list -> next); } void printlist(struct lnode *list) { if (list != NULL) { printf("%c", list -> data); printlist(list = list -> next); } } struct lnode *makelist(char *s) { struct lnode *list = NULL; if(*s) { list = (struct lnode *) malloc(sizeof(struct lnode)); list -> data = *s; list -> next = makelist(++s); } return list; }