I am reading the Link List section at C++ programming tutorial in Cprogramming.com. I need help to understand the following code better.
1. It would be great if someone could display this specific code in a diagram type display.
2. Are there only two nodes in here, root and conductor? with root data 12 and conductor data 42
3. If item #2 correct, how do I read the content of data in the 1st node (root) at the end of
main() code?
I have recently started to learn C++ and I apologize in advance if my request is too elementary.
Thanks,
Andrew
Code:struct node { int x; node *next; }; int main() { node *root; node *conductor; root = new node; root->next = 0; root->x = 12; conductor = root; if ( conductor != 0 ) { while ( conductor->next != 0) conductor = conductor->next; } conductor->next = new node; conductor = conductor->next; conductor->next = 0; conductor->x = 42; }



LinkBack URL
About LinkBacks



