Pointers in C

The pointer in C language is a variable which stores the address of another variable. This variable can be of type int, char, array, function, or any other pointer. The size of the pointer depends on the architecture. However, in 32-bit architecture the size of a pointer is 2 byte.
The following example is to define a pointer which stores the address of an integer.

int n = 10;   
int* p = &n;//p is a pointer which is pointing to the address of the variable n.
Declaring a pointer:
int *a;//pointer to int  
char *c;//pointer to char  
Pointer to array:
int arr[10];  
int *p[10]=&arr; //p is a pointer pointing to the address of the integer array arr.
Pointer to a function:
void show (int);  
void(*p)
(int) = &display; // Pointer p is pointing to the address of the function.
Pointer to structure:
struct st 
{  
    int i;  
    float f;  
}ref;  
struct st *p = &ref;  

Posted on by