DEV Community

Discussion on: Pointers

Collapse
 
pauljlucas profile image
Paul J. Lucas

This article is written keeping beginners in mind.

I know.

So to keep things simple, I did skip a lot of stuff and focused only in bare basics.

You can both keep things simple and correct. They're not mutually exclusive. For example, I would describe a variable as:

A variable is named and typed region of memory. For example:

int n;

sets aside a region of memory for an integer and makes it accessible using the name n.

I would describe a pointer declaration as:

The C language has a curiously (and some would say confusingly) unique way of declaring variables:

T expression;

that is you write some base type T, like int, char, etc., followed by an expression that yields a value of the type T. To declare a pointer, you would write something like:

int *p;

that is the ultimate type is int followed by *p which an expression that dereferences (gets the pointed-to value of) p — which means p therefore must be a pointer to int.

The other way to write simple posts is to say something, but include a note saying that the thing you just said isn't strictly true, but will do for now.