Printing an address of a variable in C
To print the address of a variable, we use "%p" specifier in C programming language. There are two ways to get the address of the variable:
- By using "address of" (&) operator
- By using pointer variable
1) By using "address of" (&) operator
When we want to get the address of any variable, we can use “address of operator” (&) operator, it returns the address of the variable.
Program:
Output
2) By using pointer variable
A pointer is the type of a variable that contains the address of another variable, by using the pointer; we can also get the address of another variable.
Read more: Pointers in C language
Program:
Output
Note: At every run output may change.
need an explanation for this answer? contact us directly to get an explanation for this answer