C help needed! (19)

1 Name: #!/usr/bin/anonymous : 2008-02-15 13:47 ID:oCqqrrfi

Lint gives me a warning at the malloc in that first loop:

warning: improper pointer/integer combination: op "="

Here's the program...it has quite a few runtime bugs, but the main compiler problem is at that malloc line. Please help!

#include <assert.h>
#include <stdio.h>

typedef struct node *node_ref;
struct node {
char *word;
node_ref link;
};

int main (int argc, char **argv) {
node_ref head = NULL;
node_ref p;
int count;
for (count = 0; count < 5; ++count) {

  node_ref node = malloc (sizeof (struct node));
assert (node != NULL);
node->word = argv[count];
node->link = head;
head = node;

}
for (p = head; p->link != NULL; p = p->link) {

  printf ("%p->{%s, %p}\n", p, p->word, p->link);

}
return 0;
}

This thread has been closed. You cannot post in this thread any longer.