Pointers and Addresses:
When we are talking about the program and its execution we will come up with addresses. All the variables, functions, arrays, etc like whatever we are using to write and execute a program all are saved in memory. Memory will be starting and ending with some memory address. The accessibility to these memories we can do only with memory addresses only. It will give the privilege to the programmer to make changes from a very base level.
It is the information about the data, where it is saved in memory. If you want the address of a variable
you can use the ’&’ address of the operator.
It is the ability of the variable to hold the address of another variable(Points to the address of another variable). The pointer is denoted ‘*’ Asteric symbol. One of the major advantages of the pointer is it will give direct access to the memory address of the variables, functions, arrays, strings, linked list etc..
The size of the pointer is depending upon the size of the memory. For eg, if the memory is 8-bit memory the pointer size will be 8 bit. If it is 16 bit then the pointer will be 16-bit memory.
Let us check an example program.
//integer variable definition
// pointer declaration
// Assigning the address of a to the pointer p.
Printf(“Value of integer a =%d”,a);
Printf(“Value of integer pointer p =%d”,p);
Printf(“Address of integer a =%d”,&a);
Printf(“Address of integer pointer p =%d”,&p);
Printf(“De-referenced value of integer pointer p =%d”,*p);