I have a few questions...
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) ); /*which struct does this point to? The actual global struct or the struct inside of the global struct?*/
root->next = NULL;
root->x=10;
conductor = root;
/I still don't get the whole if conductor or if conductor->next does not equal null concept because above I have set root->next to equal exactly that, NULL.*/
if(conductor != NULL) {..
while(conductor->next != NULL) {..
conductor = conductor->next;..
.... ..}
}
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;
}
}
Thanks in advanced...