And I am completely stumped as to why i am getting it.. for all intents and purposes, I cannot see a flaw (by eyeballing the code).
Code:typedef struct list { int number; struct list *next; } node; node *addlist(node *head, node *tail, int number) { node *temp; temp = calloc(1, sizeof(node)); temp->number = number; tail->next = temp; tail = temp; if ( head == NULL ) { head = tail; } nodecount++; return tail; } void printlist( node *head, node *tail ) { node *point; point = head; while (point) { printf("Number: %d\n", point->number); point = point->next; } } int main( int argc, char *argv[] ) { node *head = NULL; node *tail = NULL; if ( arguementscheck(argc) != 1 ) { error(1); } if ( readcheck(argv[1]) != 1 ) { error(2); } tail = addlist(head, tail, 1); tail = addlist(head, tail, 3); tail = addlist(head, tail, 5); tail = addlist(head, tail, 10); printf("Inserted %d nodes into my list.\n", nodecount); printlist(head, tail); /* No errors encountered, all tasks completed. Exit the program. */ stdexit(); }



LinkBack URL
About LinkBacks



Except for one problem now. The printlist() function prints a "0" at the first print.. but I can't see why: