Day 1 learning about linked lists. I am following an example in the textbook, and the following code compiles fine. When I go to run, however it forces the .exe file to close. Is it a code issue or am I missing a file? Using Dev c++ 5.4 right now.
Your program produces no output and receives no input. So it should just run to completion rather quickly and show you nothing as a result. Unless, by saying
forces the .exe file to close
you mean that there is an error of some sort that comes up letting you know the program had an abnormal termination.
Yes, the exact error reads "File_Name".exe has stopped working:
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.
However, since it compiles with no errors or warning I thought maybe I was missing a dev c++ file. The error only occurs when I run.
Actually your program accesses unknown memory on line 19.
p does not have a memory address assigned to it, but you are trying to access UNKOWN->link so it crashes.
This is even simpler. I expected to be able to start storing numbers in head->info after the pointer *head was defined. However the code below gives the same error. It's likely I just don't understand how the linked lists work yet. Again, this compiles but doesn't run. Is there something else I need to initialize?