New course! Every coder should learn Generative AI!
Try a free lesson+ 1
C++
What is the difference between ampersand (&) and asterix (*) in pointers?
1 Answer
+ 4
When working with pointers in general, the & symbol followed by the variable name (ex. &x) returns the address (location) of that pointer, generally as a hexadecimal value such as 0x23fe48. The * on the other hand returns the actual value being pointed at by that pointer, so if the value at the location of a pointer were 5, running the line cout << *x; will print out 5.