Re: "Mastering C Pointers"....

From: Richard Heathfield (dontmail_at_address.co.uk.invalid)
Date: 11/04/03


Date: Tue, 4 Nov 2003 06:28:29 +0000 (UTC)

Sheldon Simms wrote:

> Ok, let me try to tell you something about pointers that is (hopefully)
> precisely correct, but won't confuse you.
>
> A pointer is a kind of variable that can "point to" some object.

This isn't precisely correct. Sorry to dash your hopes.

A pointer need not be variable. For example, there exists such a thing as a
null pointer constant. Also, consider:

int main(void)
{
  int i;
  int *p = &i; /* &i is not a variable, but it is a pointer */
  return 0;
}

Of course, Alan won't learn this, at least not yet. His problem, not mine.

-- 
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton


Relevant Pages

  • Re: "Mastering C Pointers"....
    ... >>This isn't precisely correct. ... Sorry to dash your hopes. ... >>A pointer need not be variable. ... > And are functions objects? ...
    (comp.lang.c)
  • Re: "Mastering C Pointers"....
    ... >>This isn't precisely correct. ... Sorry to dash your hopes. ... >>A pointer need not be variable. ... > And are functions objects? ...
    (comp.lang.c)
  • Re: Memory Structure Pointer Problems
    ... typedef struct sta { ... char* name; ... int num_cmpnds; ... A pointer to a struct cmp is almost ...
    (comp.lang.c)
  • Re: C# - getting binary data from .lib
    ... Use Marshal.AllocHGlobal to allocate the memory and pass this IntPtr to the ... int retCode = create(id, scale, ptrImage); ... You now control the pointer returned. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Another spinoza challenge
    ... You should test against the int type's limits: ... typedef struct complex ... a pointer to an integer ... A macro is preferable because it is replaced by inline code, ...
    (comp.lang.c)