+ 10
What is the difference between these two arguments?!
(int *p = &a;) vs (int a; int *p ; p = &a)
3 Answers
+ 8
I don't see any difference. I tried both and they both work. The variable values printed out the same, but the pointers gave different addresses, as expected, since I made two sets of pointers.
https://code.sololearn.com/c3XRLIH5UKQ5/?ref=app
+ 3
int *p; //declares a variable
p = &a; // initializes a variable
int *p = &a; // does both in one line
In both cases int a has to be already declared.
+ 2
both are same
they are just different methods of writing the same stuff
in both examples *p is the pointer, &a is the address of a.
address of a is assigned to pointer p