Please tell the difference between * pointer and &pointer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 12

Please tell the difference between * pointer and &pointer

31st Dec 2016, 5:41 AM
Kavya Sree
Kavya Sree - avatar
6 Answers
+ 10
The '*' character is used in declarations of pointers. The '&' is for taking the address of something. So, if you go back to the tutorials on pointers, they would be used this way: Ninja n; Enemy *pe = &n; The asterisk says that 'pe' is a pointer to an Enemy and you are taking the 'address of' the Ninja 'n' with '&'. The asterisk is also used for dereferencing a pointer. You can use '*' to dereference the pointer like this: (*pe).attack() which would be the same as n.attack();
31st Dec 2016, 5:55 AM
Ken O'Dell
Ken O'Dell - avatar
+ 8
thank you
31st Dec 2016, 5:54 AM
Kavya Sree
Kavya Sree - avatar
+ 3
Hey I'm new and I really just followed some random people but could you help me out on this kind of stuff
2nd Jan 2017, 6:19 AM
Ed722
Ed722 - avatar
+ 3
these are two pointer operator the first "&" is address of pointer or pointer variable and second is value of pointer variable
26th Feb 2017, 4:53 PM
🇨 🇭 🇭 🇦 🇹 🇷 🇦 🇵 🇦 🇱
🇨 🇭 🇭 🇦 🇹 🇷 🇦 🇵 🇦 🇱 - avatar
+ 2
the (*) is used to declare the content of a pointer whiles the (&) is used to know the memory location of the pointer, for a pointer is a variable that takes the memory address of another variable as it value.
8th Apr 2017, 6:10 PM
Enock Akotam Asambo
Enock Akotam Asambo - avatar
0
hallo kavya sree.
23rd Mar 2017, 4:19 PM
Majedul haq
Majedul haq - avatar