int*p=&var ---- what is this???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

int*p=&var ---- what is this????

14th Oct 2016, 3:41 PM
Chandan Jha
Chandan Jha - avatar
3 Answers
+ 1
It is simply example of declaring and initialising a pointer at the same time , it shortens the code size. Int var; Int *ptr ; ptr = &var ; Or simply you can write Int var; Int *ptr=&var ;
25th Oct 2016, 7:34 AM
Akshay Kumar Tak
Akshay Kumar Tak - avatar
This is example if work with a pointer variable. The pointer variable does not contain any value (as number, string,..], but points to another variable (or later into dynamic variable in memory]. So the example says int*p=&var; declare p as pointer to integer variable and points to variable var...
14th Oct 2016, 4:24 PM
Petr Hatina
Petr Hatina - avatar
as Petr said, p is essentially a variable that stores the memory address of another variable.
14th Oct 2016, 7:49 PM
Fhatuwani Luvhengo
Fhatuwani Luvhengo - avatar