Re: Pointer Pointing Itself



pete wrote:
wade@xxxxxxxxxx wrote:
KBG wrote:
where could [a pointer pointing at itself] be this used ?

char* a = 0; /* no string */
char* b = ""; /* empty string */
void* c = 0; /* no list */
void* d = &d; /* empty list */

I consider a null pointer to be an empty list,
that is to say, a list with zero number of nodes.
I don't see any point in distinguishing "empty list" from "no list".

I don't think "d" is an empty list, I think it is a cyclic list of no
values. In OCaml, the equivalent is:

type t = Nil | Cons of t

--
Dr Jon D Harrop, Flying Frog Consultancy
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
.



Relevant Pages

  • Re: When fopen() fails
    ... pete wrote: ... Null is more general than "zero", ... null pointer _constant_). ... Richard ...
    (comp.lang.c)
  • Re: Pointer Pointing Itself
    ... KBG wrote: ... I consider a null pointer to be an empty list, ... a list with zero number of nodes. ...
    (comp.programming)
  • Re: When fopen() fails
    ... Richard Bos wrote: ... A null pointer will compare equal to zero, ...
    (comp.lang.c)
  • Re: a question about a string
    ... TN is a null pointer, ... *TN is a constraint violation. ... TS points to a byte that has a value of zero. ...
    (comp.lang.c)
  • Re: (part 10) More Schildt-like errors in Dicky Heathens book
    ... like mallocif mallocreturns a non-NULL pointer. ... If one is using a debugging malloc which checks that all accesses are ... when sz is zero, it gives the debugging allocator an opportunity to ...
    (comp.lang.c)