Doubt in pointer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Doubt in pointer

I have recently learnt concepts of pointers in C++ and I have found, in few programs, to assign a pointer to the address of a variable, sometimes they use the line of code - int *p = &num ; and sometimes they use - int p = &num ; So are these lines of codes equivalent and the placing of asterics sign is insignificant? Please help me have a clear idea.

7th Feb 2018, 1:40 PM
something
2 Answers
+ 8
You cannot do int p = # The address of num can only be stored in a pointer. I suppose you mean: int& p = num; ?
7th Feb 2018, 1:49 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
https://code.sololearn.com/cFK8o7i1XKyh/?ref=app Check this out. I think its clear enough.
7th Feb 2018, 2:07 PM
Akib
Akib - avatar