I think I am asking a question that might already have an answer here but I am afraid I was unable to figure it out from the linked page.
I am doing a linked list in c++, and scanning them from the start until the pointer to the next element in list is null. After some total garbage (this time used metaphorically) for an our I figured out I forgot to set the said pointer to the last element explicitely to NULL, because I was thinking an unset pointer is by default null.
I know, that unset values in C/++ cotains by default some garbage which causes troubles, like in this case, but I wonder is there a way to set them automatically to null, in case i forget to do so? I did not find much info in a web search.
Sorry if the question is rather rookie.