[Question] NULL pointers...
So i learned about pointers a while back, and i figured since i was concentrating on rereading tutorials before i learn windows API and go ahead and tackle a 1500 page book i would look over them again, seeing as they're essential for hacking.
I came across null pointers, and they were explained in 4 lines. I know that in order to create a pointer that basically points to nothing you just make the value of the address its pointing to 0 (int *ptr = 0

or use the NULL keyword, which i didnt bother to learn how to use.
The tutorial also said that null pointers are useful in many situations, although i'm not quite sure when they would be used...
so my question isn't necessarily about how to incorporate null pointers in my code, but where i would use them... like in what situation would i need to make pointers that point to nothing....?
thanks :x
malloc/new for allocation
free()/delete for deallocation
actually most of the times you clear pointers just to be sure that you don't create memory leaks with your application. not that it is really necessary.
And a pointer is something that points to a memory location, so... it's just a pointer. The problem is in what is was pointing at.
Let's say you have the pointer pointed at some place on memory and placed a string in there. If you point it to null without clearing memory first, you are creating a memory leak. With this i mean, you are actually leaving the string in memory, just not pointing to it. That's why you should always clear the memory after using the pointer for something else, or after finishing using it.
(after the application close, windows will clear the memory, but still, get used to it)
Edit: Just saw that master posted pretty much this.. Sorry >_<