I have seen person in another place talking about deleting pointers. I
know in C++ they have new but can that be done in C? All I am aware of is
the NULL pointer. Just thought I'd inquire.
A pointer is really just a big number, indicating a specific place in
memory. "deleting a pointer" makes about as much sense as "deleting the
number 2".
You can delete or invalidate the object the pointer points to though.
For dynamically allocated objects (i.e. with malloc() or friends in C,
or with the "new" operator in C++), you can invalidate the object by
releasing the allocated memory (i.e. with free() in C, "delete" in C++).
Pointers may also become invalid if they point to an automatic object
which ceases to exist.
An invalidated pointer still holds the number it held before, but trying
to access the object leads to undefined behaviour. It may access the old
object, if nothing has overwritten it yet. It may access random data. Or
it may crash your program.
It is a good idea, in C, to assign the value NULL to a pointer
variable after using free() on it. In that case, if the program still
accidentally dereferences the pointer, it will stop with a null pointer
derefence error instead of meddling with data it should not meddle with.
This doesn't prevent all possible errors though.