What is the difference between variables and pointers?
Whist reading an article outlining differences in [OO and Functional programming](http://blog.cleancoder.com/uncle-bob/2014/11/24/FPvsOO.html) I came across function pointers. It has been a while since I completed 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. They can be considered to point to the data that is contained in that memory address if such data exists. Or, as in the case in the article, they might indicate the entry point to a section of code and can be used to call that code. Why is this different from a variable? Variables are symbolic names for memory addresses and compilers will replace the name with the actual address. This means that variables contain references to memory locations and can be considered to point to the data at that address if such data exists. If the difference is in behaviour (maybe a pointer cannot be reassigned at runtime, or can only be assigned a symbolic variable name, not any other value) doesn't that mean it is just a variable of a particular type, the pointer type? In just the same way a variable declared to be of type integer is restricted by the compile in what it can be used for. What am I missing here?
You're correct, variables and pointers are very similar: they both point to some area in memory that contains the data. The difference is how the compiler interacts with these different types. Consider two variables of different types (integer vs string maybe). Both of these variables at a lower level are the same; they both point to an address which have some number of bytes representing data. The difference is in how the compiler interacts with those bytes knowing that one set of bytes represents an integer and the other represents a string. So for example when you place a '+' in between two integers it does something totally different than it would if you placed a '+' between two strings. This also applies to pointers. A pointer is simply a number; the fact that it is a pointer tells the compiler that the number represents an address to a certain type. Just like with the example of a '+' sign having different meanings between different types the '*' sign has a different meaning between types. To an integer '*' means multiplications where for a pointer '*' means go to my address and get the data at that location in memory. So yes you can store addresses in normal unsigned long variables but compilers have built in tools which make it a lot more convenient to store addresses into pointers.