The program you will download (below) contains a very trivial linked list. It works well as defined as long as you create pointers to insert into the list. In theory, the reference of a variable is a legal pointer of the same type as the variable.
The program contains a correct version of the program, where if you select insert from the list menu, a pointer to a node containing a string is placed in the list. If you replace this section of code with the one commented out, you will in effect pass in a reference to a local node variable, not a standard pointer. Run this program and after the second insert, the program freezes. Place a breakpoint in the print routine and see why it freezes by checking the pointer addresses referenced. What is the cause of this problem in terms of how local memory is allocated in this type of stack oriented runtime memory manager? Write a few paragraphs (please type this) about what happened.
Click here for the test program.