Let's replace the word "pointer" with a datatype that's hopefully more familiar, like an int:

int n = 42;

Here 42 is an int value, and n is a variable that holds an int. You could call n an "int variable". An int is a number like 42 or -25315685, and an int variable holds these numbers. Once you have a variable you can assign different numbers to it. Nothing confusing so far?

A pointer is just like an int: a number. It happens to be a number that identifies a memory location, and if something is stored in that memory location you can call it an address. Like an int, a pointer can be stored in a variable. A variable that stores a pointer could be called a pointer variable.

So, what's the difference between a pointer and a pointer variable? The first one is a value, like a number, the second stores these values. But often people refer to variables by their values that they store; people don't call n an "int variable" but just int, even though it can at different times store different ints. In this text I'll do the same and sometimes write pointer when I mean a pointer variable; hopefully the distinction will be clear.

Is a pointer always an address? This is a question about the meaning of the word "address" more than anything else. A pointer is always an address in the sense that it corresponds to a memory location in one way or another, it's an "address" for that memory location. But on the other hand, if the memory location is not accessible to the program or doesn't have anything useful stored in it, is it really an "address" for anything?

Let's now investigate the following code:

int *p;
p = &n;

The first line declares a pointer variable called p. The pointers that can be stored into p are memory locations for int data; this is important for reasons that we'll see later. We still don't give p any value, so the pointer it stores is arbitrary. It certainly doesn't store the address of anything useful; it may even point to an area of memory inaccessible to the program.

In the second line we take the address of the n variable with the &-operator and assign it to p. Now p stores the address of n, the memory location where the value of n is stored.

What can we do with a pointer? We can read and write to the memory location that the pointer identifies. To do this we "dereference" the pointer with the *-operator, and then (*p) can be used just like you can use n. For example, you can write a new value into n with this:

*p = 123;

It's at this point that it becomes apparent why we need to know the type of data that p can point to: otherwise you can't know what you could assign to (*p).

Another reason why it's important to know the type of data that p can point to is pointer arithmetic. For example p+1 is a pointer to the int stored in memory right after n; if p was a pointer to a big data structure p+1 would be a pointer to a data structure of the same type stored right after it. For this the compiler must know the size of what the pointer points to.

Answer from Joni on Stack Overflow
Top answer
1 of 6
10

Let's replace the word "pointer" with a datatype that's hopefully more familiar, like an int:

int n = 42;

Here 42 is an int value, and n is a variable that holds an int. You could call n an "int variable". An int is a number like 42 or -25315685, and an int variable holds these numbers. Once you have a variable you can assign different numbers to it. Nothing confusing so far?

A pointer is just like an int: a number. It happens to be a number that identifies a memory location, and if something is stored in that memory location you can call it an address. Like an int, a pointer can be stored in a variable. A variable that stores a pointer could be called a pointer variable.

So, what's the difference between a pointer and a pointer variable? The first one is a value, like a number, the second stores these values. But often people refer to variables by their values that they store; people don't call n an "int variable" but just int, even though it can at different times store different ints. In this text I'll do the same and sometimes write pointer when I mean a pointer variable; hopefully the distinction will be clear.

Is a pointer always an address? This is a question about the meaning of the word "address" more than anything else. A pointer is always an address in the sense that it corresponds to a memory location in one way or another, it's an "address" for that memory location. But on the other hand, if the memory location is not accessible to the program or doesn't have anything useful stored in it, is it really an "address" for anything?

Let's now investigate the following code:

int *p;
p = &n;

The first line declares a pointer variable called p. The pointers that can be stored into p are memory locations for int data; this is important for reasons that we'll see later. We still don't give p any value, so the pointer it stores is arbitrary. It certainly doesn't store the address of anything useful; it may even point to an area of memory inaccessible to the program.

In the second line we take the address of the n variable with the &-operator and assign it to p. Now p stores the address of n, the memory location where the value of n is stored.

What can we do with a pointer? We can read and write to the memory location that the pointer identifies. To do this we "dereference" the pointer with the *-operator, and then (*p) can be used just like you can use n. For example, you can write a new value into n with this:

*p = 123;

It's at this point that it becomes apparent why we need to know the type of data that p can point to: otherwise you can't know what you could assign to (*p).

Another reason why it's important to know the type of data that p can point to is pointer arithmetic. For example p+1 is a pointer to the int stored in memory right after n; if p was a pointer to a big data structure p+1 would be a pointer to a data structure of the same type stored right after it. For this the compiler must know the size of what the pointer points to.

2 of 6
8

The difference between a pointer value and a pointer variable is illustrated by:

int swap_int(int *i1, int *i2)
{
    int t = *i1;
    *i1 = *i2;
    *i2 = t;
}

int main(void)
{
    int  v1 = 0;
    int  v2 = 37;
    int *p2 = &v2;
    printf("v1 = %d, v2 = %d\n", v1, v2);
    swap_int(&v1, p2);
    printf("v1 = %d, v2 = %d\n", v1, v2);
    return 0;
}

Here, p2 is a pointer variable; it is a pointer to int. On the other hand, in the call to swap_int(), the argument &v1 is a pointer value, but it is in no sense a pointer variable (in the calling function). It is a pointer to a variable (and that variable is v1), but simply writing &v1 is not creating a pointer variable. Inside the called function, the value of the pointer &v1 is assigned to the local pointer variable i1, and the value of the pointer variable p2 is assigned to the local pointer variable i2, but that's not the same as saying &v1 is a pointer variable (because it isn't a pointer variable; it is simply a pointer value).

However, for many purposes, the distinction is blurred. People would say 'p2 is a pointer' and that's true enough; it is a pointer variable, and its value is a pointer value, and *p2 is the value of the object that p2 points to. You get the same blurring with 'v1 is an int'; it is actually an int variable and its value is an int value.

Top answer
1 of 3
8

Your question is interesting in several ways, as it requires careful distinctions for several issues. But your vision seems to me to be essentially correct. I did not read your reference before writing most of this answer to avoid biasing my answer.

First, your statement Variables are symbolic names for memory addresses, it is almost correct, but confuses the concept and its usual implementation. A variable is actually just a container that can contain a value that can be changed. Usually, this container is implemented on a computer as a bock of memory space, characterized by and address and a size since variables may contain object that require representations with more or less information.

But I will consider mostly a more abstract point of view of the semantics of languages, independently of implementation techniques.

So variables are just containers from an abstract point of view. Such a container need not have a name. However, languages often have variables that are named by associating to it an identifier, so that uses of the variable can be expressed by the identifier. A variable can actually have several identifiers through various aliasing mechanism. A variable can also be a subpart of a larger variable: an example is a cell of an array variable, which can be named by specifying the array variable and the index of the cell, but could as well be also associated with identifiers through aliasing.

I am deliberately using the word container that is somewhat neutral, to avoid invoking other words that may be semantically loaded technically. It is actually close to the concept of reference described in wilipedia, which is often confused with a memory address. The word pointer itself is often understood as a memory address, but I do not think that is meaningful when considering most high-level languages, and probably inappropriate in the discussion paper you refer to (though addresses can be used), as it is inappropriately referring to a specific implementation. However, it is appropriate for a language like C, which is supposed to be much closer to implementation concepts and the machine architecture.

Actually, if you look at variables or values at the implementation level, there may be several complex systems of indirection, of "machine level pointers", but that are (and should be) invisible to the user, so that the abstract point of view I develop can be valid. For most programming languages, the user should not have to worry, or even know, about implementation, as implementation can vary a lot for a given language. This may not be true for some languages, such as C, that are intentionally close to the machine architecture, as an advanced substitute for assembly languages that are in almost direct relation to explicit binary coding, but far too low level for convenient use in most situations.

What the user of a language should know, and sometimes it should be even less than that, is what are values and associated operations, where they can be contained, how they can be associated to names, how the naming system works, how can new kinds of values be defined, etc.

So another important concept is identifiers and naming. Naming an entity (a value) can be done by associating an identifier with a value (usually in a declaration). But a value can also be obtained by applying operations to other named values. Names can be reused, and there are rules (scoping rules) to determine what is associated to a given identifier, according to context of use. There are also special names, called litterals, to name the values of some domains, such as integers (e.g. 612) or boolean (e.g. true).

The association of an unchanging value with an identifier is usually called a constant. Litterals are constants in that sense.

"Value containers" can also be considered as values, and their association with an identifier is a variable in the usual "naive" sense that you have been using. So you might say that a variable is a "container constant".

Now you might wonder what is the difference between associating an identifier with a value (constant declaration) or assigning a value to a variable, i.e. storing the value in the container defined as a container constant. Essentially, declaration may be seen as an operation that defines a notation, that associate an identifier which is a syntactic entity to some value which is a semantic entity. Assignment is a purely semantics operation that modifies a state, i.e. modifies the value of a container. In some sense, declaration is a meta concept with no semantic effect, other than providing a naming (i.e. syntactic) mechanism for semantics entities.

Actually, assignments are semantic operations that occur dynamically as the program is executed, while declarations have a more syntactic nature and are usually to be interpreted in the text of the program, independently of execution. This is why static scoping (i.e. textual scoping) is usually the natural way to understand the meaning of identifiers.

After all this, I can say that a pointer value is just another name for a container,and a pointer variable is a container variable, i.e. a container (constant) that can contain another container (with possible limitations on the containing game imposed by some type system).

Regarding code, you state [pointers] might indicate the entry point to a section of code and can be used to call that code. Actually this is not quite true. A section of code is often meaningless alone (from high level or implementation point of view). From a high-level point of view, code usually contains identifiers, and you have to interpret these identifiers in the static context where they were declared. But there is actually a possible duplication of the same static context, due essentially to recursion which is a dynamic (run-time) phenomenon, and the code can only be executed in an appropriate dynamic instance of the static context. This is a bit complex, but the consequence is that the proper concept is that of a closure that associate a piece of code and an environment where the identifiers are to be interpreted. The closure is the proper semantic concept, i.e. is a properly definable semantic value. Then you can have closure constants, closure variables, and pointers to closures, which are containers that can contain another container containing a closure.

A function is a closure, usually with some parameters to define or initialise some of its entities (constants and variables).

I am skipping many variations on the uses of these mechanisms.

Closures can be used to define OO structures in imperative or functional languages. Actually, early work on OO style (probably before the name) was done that way.

The paper you reference, which I skimmed quickly, seems to be an interesting one, written by a competent person, but possibly not an easy reading if you do not have significant experience with a variety of languages and their underlying computational models.

But remember: many things are in the eyes of the beholder, as long as he preserves a consistent view. Points of view may differ.

Does this answer your question?

PS: This is a long answer. If you consider some part of it inadequate, please be explicit about which it is. Thank you.

2 of 3
2

The difference is by definition and application, a pointer is a specialized variable to hold a memory address of another variable; in OO terms a pointer would perhaps be considered to inherit its behavior from a general class called variable.

Discussions

Difference between setting a variable, and setting a pointer
Matt Lebl is having issues with: Functionally, what's the difference? Doug uses the two for his NSNumbers, "mike" and "pi" respectively, and it seems to have no impact on the re... More on teamtreehouse.com
🌐 teamtreehouse.com
2
September 22, 2014
What is the difference between a pointer variable and simply storing an address in a variable?
You can't dereference a non-pointer More on reddit.com
🌐 r/C_Programming
21
32
April 14, 2022
Pointers vs Variables - Talk - GameDev.tv
Just a note: I could be completely wrong in my understanding Pointers vs Variables Variables So my understanding of pointers is used for better performance. When you declare a standard variable, it stores it's value t… More on community.gamedev.tv
🌐 community.gamedev.tv
0
July 2, 2017
C: Whats the difference between pointer = variable and pointer = &variable? - Stack Overflow
The textbook i'm reading explains that pointers are variables which hold the starting address of another variable, and that they are defined with a type of data to point to. Why can you assign a po... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Quora
quora.com › What-is-the-difference-in-a-pointer-and-a-variable
What is the difference in a pointer and a variable? - Quora
Answer (1 of 6): first a pointer is a “type” of variable as it also stores data (a pointer data). to understand how pointers work you need to understand how memory works on computer. you can have a lot of data types but,in memory all of ...
Top answer
1 of 2
2
Pointers are kind of confusing and many people struggle with understanding them at first, but after a while you start to get it. pointers are variables that store memory addresses. So all pointers are variables, but not all variables are pointers. its important to note that all objects in objective c are pointers. Because of this, you use them all the time and can pretty much treat them as any other variable. you dont have to dereference (this word is covered more in depth below) them since most methods take pointers to objects as parameters, not the actual objects themselves. below is a simple example of using pointers with int variables. int number = 3; //value of number is 3 int *numberPointer = number; //value of numberPointer is the location in memory where number is stored. in the code above, number is a regular int variable. numberPointer points to number. the value of number is 3. the value of numberPointer is the memory address of number. I could assign the value of numberPointer to another pointer variable like so: int *anotherPointer = numberPointer; //anotherPointer now points to the same memory address as numberPointer notice that the value of numberPointer is the memory address of number, it is NOT the value of number. in order to get at the value of the variable that numberPointer points to, you must dereference the pointer. to dereference it, you just put a * in front of the pointer name. below I assign the value of the variable that numberPointer points to to a new variable by dereferencing it: int newNumber = *numberPointer; ///newNumber is assigned the value 3, since thats the value that numberPointer pointed to the difference between a pointer to an int, and a regular int, is that the int variable actually stores the value of that int, whereas the pointer to the int just stores the memory address where the value is stored. the advantage of pointers is that they are very small and easy to pass around. say you had an array that contained a million items and you declared that as a regular array, anytime you passed that array around it would have to pass all one million of the items which is huge and time consuming. If you had an array pointer that pointed to an array containing a million items, anytime you passed that pointer around it would just be passing the memory address, which is tiny. Again, all objects in objective c are pointers, so they are used all the time. they are used so much you dont even have to think about it. you (usually) dont have to worry about ever dereferencing them. the only thing you have to remember is to put a * in front of their name when you first declare them. The important thing to remember is that using pointers makes things easier on the computer. There are many other advantages as well, but thats one of the main ones.
2 of 2
0
A variable is stored on the stack while an object, which needs a pointer to reference it, is stored on the heap. The stack is local while the heap is not. A variable is a primitive and is usually smaller than the size of an object. However the size of a pointer is the same size as an int primitive, so it improves performance to pass around the pointers instead of the objects themselves in method calls. Use a primitive when you don't need any special functionality and want to preserve memory. Use an object when you want the properties or methods that come along with that object's class.
🌐
Educative
educative.io › answers › what-is-the-difference-between-a-pointer-and-a-variable-in-cpp
What is the difference between a pointer and a variable in C++?
Using variables can be less efficient ... memory location, it is called a pointer. As the name suggests, the pointer always points to a specific memory location....
🌐
Sanfoundry
sanfoundry.com › c-tutorials-difference-between-pointer-ordinary-variable
Difference between Pointer and Ordinary Variable in C
December 31, 2025 - A pointer is a variable that stores the memory address of another variable. Instead of holding a direct value, it holds the location where the value is stored in memory. This allows for indirect access and manipulation of variables.​
Find elsewhere
🌐
GameDev.tv
community.gamedev.tv › unreal courses › talk
Pointers vs Variables - Talk - GameDev.tv
July 2, 2017 - ###Just a note: I could be completely wrong in my understanding #Pointers vs Variables ###Variables So my understanding of pointers is used for better performance. When you declare a standard variable, it stores it’s value type and not the address at the point it was created.
🌐
Wyzant
wyzant.com › resources › ask an expert
What is the difference between variables and pointers? | Wyzant Ask An Expert
April 12, 2019 - Whist reading an article outlining ... my Computer Science degree (2003) and so I looked up pointers to refresh my memory. Pointers are variables that contain a reference to a memory address....
🌐
Florida State University
cs.fsu.edu › ~myers › c++ › notes › pointers1.html
Pointer Basics
Although all pointers are addresses (and therefore represented similarly in data storage), we want the type of the pointer to indicate what is being pointed to. Therefore, C treats pointers to different types AS different types themselves. int * ip; // pointer to int char * cp; // pointer to char double * dp; // poitner to double · These three pointer variables (ip, dp, cp) are all considered to have different types, so assignment between ...
🌐
NTU
www3.ntu.edu.sg › home › ehchua › programming › cpp › cp4_PointerReference.html
C++ Pointers and References
As illustrated, a variable (such as number) directly references a value, whereas a pointer indirectly references a value through the memory address it stores. Referencing a value indirectly via a pointer is called indirection or dereferencing. The indirection operator (*) can be used in both ...
🌐
Quora
quora.com › What-is-the-difference-between-situations-using-a-pointer-and-a-variable
What is the difference between situations using a pointer and a variable? - Quora
The only difference being, pointers have a special - hidden, ulterior motive - some undercover spy, and variables being the usual, with a definite motive - some casual man. ... Stake: Online Casino games - Play & Win Online.
🌐
Quora
quora.com › What-is-the-difference-between-a-pointer-and-a-regular-variable-in-programming-Do-pointers-need-to-be-declared-as-pointers-before-being-used
What is the difference between a pointer and a regular variable in programming? Do pointers need to be declared as pointers before being used? - Quora
The address in the pointer (its value) is a location in memory where some data is or can be put. So a pointer is a locator variable — not the data, but the index to the data location. The pointer when you declare it is ...
🌐
Quora
quora.com › Whats-the-difference-between-a-pointer-and-a-pointer-variable
What's the difference between a pointer and a pointer variable? - Quora
Answer (1 of 6): A pointer is nothing more than an address where as a pointer variable is a variable that is storing this address. int a; int *p =&a; Here p is a pointer variable which is pointing to the integer variable a whereas &a is the ...
🌐
Quora
quora.com › What-is-the-difference-between-a-variable-and-a-pointer-in-C-C-What-is-the-purpose-of-each-one
What is the difference between a variable and a pointer in C/C++? What is the purpose of each one? - Quora
Answer (1 of 3): Pointer is a variable, a type of a variable. Variable is a type having, occupying, physical space in memory or CPU internal registers. Type is a meta-data, eg INT.
🌐
Brainly
brainly.in › computer science › secondary school
how is pointer variable different from normal variable ?​ - Brainly.in
February 15, 2023 - A pointer variable (or pointer in short) is basically the same as the other variables, which can store a piece of data. Unlike normal variable which stores a value (such as an int, a double, a char), a pointer stores a memory address.
🌐
Stack Overflow
stackoverflow.com › questions › 44872556 › c-whats-the-difference-between-pointer-variable-and-pointer-variable
C: Whats the difference between pointer = variable and pointer = &variable? - Stack Overflow
Explore Stack Internal ... The textbook i'm reading explains that pointers are variables which hold the starting address of another variable, and that they are defined with a type of data to point to.
Top answer
1 of 7
9

Whoever explained this to you is wrong in this case:

#include <stdio.h>

int main() {
    int a = 5; //variable a has value 5 put it
    //a does have an address
    int b = a; 
    //variable b is created, it has its own seperate memory address.
    //in this case the CONTENTS of a (5) are dumped inside b
    return 0;
}

saying int b=a; will not make the variables aliases of each other.

What you heard about is this:

//...
int a=1;
int *b = &a; //create a pointer called b and make it point to a 
//(set it equal to address of a)

in your case you have:

memory addresses:         variable name           value stored at memory address
1000                      a(int)                    5
1004                      b(int)                    5

obviously changing values of a and does not affect each other

in the case I described you have this:

memory addresses:         variable name           value stored at memory address
1000                      a(int)                    5
1004                      b(int*)                   1000

as you can see, since b is a pointer, its actual value is the address of a.

so doing *b=3; will change the value of a

2 of 7
5

When you declare

int a = 1;

Compiler allocate memory for sizeof(int) bytes and name that data location (or memory block) a and place a value 1 in that block. In a very simple way a variable is a named location of data.

You can think of it as putting the value assigned in a box with the variable name as shown below:

And for all the variables you create a new box is created with the variable name to hold the value.

Assigning one variable to another makes a copy of the value and put that value in the new box.

a = 2;
int b = a;

So, a and b are not pointers but are the names of different memory blocks having their own addresses.

🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1292480 › is-it-a-pointer-or-a-variable
Is it a pointer or a variable? - Microsoft Q&A
May 26, 2023 - I didn't mean to say that a pointer is less than a variable, but it's expression should not be like a variable in a program, and the asterisk (*) should be there with the pointer where ever it is defined in a program. This will make easy for a programmer to read and make a difference between a variable and a pointer.