Home » C Programs » Address of Variable in C

Address of Variable in C

A pointer is a variable whose value is the address of another variable, or the memory location’s direct address. Before using a pointer to store any variable address, just like any other variable or constant, you must declare it.

Pointer in C

In C, a pointer is a variable that stores the address of another variable. This variable can be of any type, including int, char, array, function, or pointer. The pointer’s size is determined by the architecture. However, in 32-bit architecture, a pointer is 2 bytes in size. 

A variable that stores the address of another variable is known as a pointer. In contrast to other variables that hold values of a specific type, a pointer variable holds the address of a variable. An integer variable, for example, holds an integer value, whereas an integer pointer holds the address of an integer variable. 

Address of Pointer in C Program

A variable that stores the address of another variable is known as a pointer. In contrast to other variables that hold values of a specific type, a pointer variable holds the address of a variable. An integer variable, for example, holds or stores an integer value, whereas an integer pointer holds the address of an integer variable. 

A pointer is a variable that stores the address of a memory location. Pointers are used to keep track of the addresses of other variables or memory items. Pointers are extremely useful for another type of parameter passing known as Pass By Address. For dynamic memory allocation, pointers are required.

Address of Variable in C

//address of variable in c 
#include <stdio.h>
int main()
{
int var = 2; 
int *p;
p = &var; 
printf("Address of the variable %d \n\n", &var);
printf("\n\nAddress stored in pointer variable p is: %d", p);
printf("\n\nValue of var variable %d ", *p);
return 0;
}

Output:

Address of the variable -1330026908

Address stored in pointer variable p is: -1330026908

Value of var variable 2