0
& C
What does & mean in C???
2 Antworten
+ 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
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:)