Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // $Id: list3.c,v 1.1 2012-02-14 23:52:07-08 - - $
- #include <assert.h>
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct node *node_ref;
- struct node {
- char *word;
- node_ref link;
- };
- int main (int argc, char **argv) {
- node_ref head;
- for (int argi = 0; argi < 5; ++argi) {
- node_ref mynode = malloc (sizeof(node_ref));
- assert (mynode != NULL);
- mynode->word = argv[argi];
- mynode->link = head;
- head = mynode;
- free(mynode);
- }
- for (node_ref curr = head; curr->link != NULL; curr = curr->link) {
- printf ("%p->mynode {word=%p->[%s], link=%p}\n",
- curr, curr->word, curr->word, curr->link);
- }
- return 9;
- }
Add Comment
Please, Sign In to add comment