0

& C

What does & mean in C???

8th Nov 2020, 9:35 PM
Whats My True Name???
Whats My True Name??? - avatar
3 Réponses
+ 3
In C, & is a unary operator that gives the memory address of a variable expression. If you have a varable, int x = 50; you can use &x to determine where in memory x is located. int *ptr; ptr = &x; Now ptr holds the memory address of x where the value 50 is stored. Of course we can use x to print 50. And now we can use ptr to print 50, too, if we dereference the pointer address by using *ptr: printf("%d %d\n", x, *ptr); // prints 50 50
8th Nov 2020, 9:51 PM
Brian
Brian - avatar
0
& is for address which can be stored in a pointer variable. int *ptr; ptr=&a; so address of a as in this case. We can also use && but for a different purpose:)
11th Jun 2022, 8:15 PM
Ranit Ghosh
Ranit Ghosh - avatar