answersLogoWhite

0

The dereference operator. In C, we use the * operator for this. Note that the * symbol has several meanings in C (multiplication, pointer declaration and pointer dereferencing). The meaning is determined from the context in which it is used.

int x, y; /* integer variables */

int* p; /* pointer variable (pointer to int) */

x = 42; /* assign a value to the x variable */

p = &x; /* assign the address of the x variable to the pointer variable p */

y = *p; /* assign the value pointed to by p (42) to the variable y */

User Avatar

Wiki User

9y ago

Still curious? Ask our experts.

Chat with our AI personalities

RossRoss
Every question is just a happy little opportunity.
Chat with Ross
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
More answers

Under C, the address of a variable or a function can be obtained by prefixing the name with an ampersand (&), which is called a "reference operator". The address is typically stored in a pointer variable. To access the value in a pointer variable, an asterisk (*) is used, which is called a "dereference operator".

For instance:

void dosomethinguseless()

{

int x=50;

int *y;

y=&x;

printf("%d, %d\n", x, *y);

}

- First, an integer variable called "x" is declared and preloaded with the value "50".

- Next, a variable called "y" is declared as an integer pointer.

- After that, the address of "x" is stored into "y", so that "y" now points to the address where the value of "x" is stored.

- Finally, both variables are printed to demonstrate that they, in one fashion or another, represent the value "50".

See the related link below for more information on C pointers.

User Avatar

Wiki User

12y ago
User Avatar

pointer is used to know the address of avariable

User Avatar

Wiki User

12y ago
User Avatar

It is '&' in C

User Avatar

Wiki User

11y ago
User Avatar

Arrow operator

User Avatar

Anonymous

4y ago
User Avatar

Add your answer:

Earn +20 pts
Q: Which operator is use to find address of a variable?
Write your answer...
Submit
Still have questions?
magnify glass
imp