Anything else you feel like adding....Code:#include <stdio.h> #include <stdlib.h> struct node { int x; struct node *next; }; int main(void ) { struct node *root; struct node *conductor; root = malloc( sizeof(struct node) ); root->next = NULL; root->x=10; conductor = root; if(conductor != NULL) { /*At this point conductor does not = NULL*/ while(conductor->next != NULL) { /*This line confuses me. conductor->next does = NULL. Doesn't it? I didnt initialize the pointer inside of the global struct to NULL but did set a dummy node to equal NULL with the struct conductor right? Or am I just confused?*/ Â..Â..Â..Â..conductor = conductor->next; /*What exactly does this do? I want to say it traverses down the list. But am not sure.*/ Â..Â..Â..Â..} } conductor->next = malloc( sizeof(struct node) ); conductor = conductor->next; if(conductor = NULL) { fprintf(stderr, "Out of memory.\n"); else{ conductor->next = NULL; conductor->x = 20; } }



6Likes
LinkBack URL
About LinkBacks





