Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!helios!stat!john From: john@stat.tamu.edu (John S. Price) Newsgroups: comp.lang.c Subject: Re: What is the really pointing to? Message-ID: <5262@helios.TAMU.EDU> Date: 8 May 90 09:58:14 GMT References: <21910@dartvax.Dartmouth.EDU> Sender: usenet@helios.TAMU.EDU Distribution: comp Organization: ^ Lines: 34 In article <21910@dartvax.Dartmouth.EDU> pete@othello.dartmouth.edu (Pete Schmitt) writes: >What is the null pointer really pointing to? >[declaration deleted] >struct entry n1, n2, n3, *list_pointer = &n1; > >n1.next = &n2; >n2.next = &n3; >n3.next = (struct entry *) 0; /* <-- what is this pointing to, address 0? */ Oh no.. Here we go again. The (struct entry *) 0 is not address 0. The NULL pointer is not pointing to ANYTHING. Nothing. Zip. Zilcho. It is exactly what it is called. Nobody really cares what the pointer actually contains, although it is usually a bit pattern of zero (Yes, I know it's not always. Segmented arch. can cause this to be weird) It doesn't have to be a bit pattern of zero, though. But, nobody cares what it is. THAT pattern, whatever it is, is the NULL pointer. C uses 0 to represent for a null pointer for lack of anything better. 0 is overloaded to mean two things, depending on it's context. If it is in an integer context, it means the number zero. If it is used in a pointer context, as in the above context, then it means a null pointer, whatever that value might be. 0 is a SPECIAL CASE to the compiler. A null pointer doesn't pointer anywhere. That's its purpose. To point nowhere. This was just recently discussed, but I guess that you missed that discussion. -------------------------------------------------------------------------- John Price | It infuriates me to be wrong john@stat.tamu.edu | when I know I'm right.... --------------------------------------------------------------------------