+ 1

What is the difference between address operator& and pointer*?

*var means the value whatever var points to &var means the address of variable var. I m confused how to use pointers. And what is the role of & address operator

28th Mar 2021, 11:23 AM
isbah
isbah - avatar
2 Respostas
+ 6
Pointer is used to hold the address of a variable whereas address operator is for providing the address of the variable to the pointer. Note: pointer is a variable but address operator is a operator.
28th Mar 2021, 12:16 PM
Kashyap Kumar
Kashyap Kumar - avatar
0
Think of how the data in computers is somewhere on the computer. Even programs we write. Each variable is stored in memory at an address (a hex number representing a memory location) when a variable is preceded with '&', it refers to that variables memory address. if: int x = 5; //and int x_ptr = &x; // <--- x's memory address // then printf("pointer value: %d\nx value: %d\n", *(x_ptr), x); // output pointer value: 5 x value: 5
28th Mar 2021, 11:44 AM
Slick
Slick - avatar