+ 2
General pointer question?
if I am declaring Int *x; Int n=5; *x=&n; why it is showing error explain?
2 odpowiedzi
+ 6
*x = &n is a common mistake made by beginners when dealing with pointers.
The 'point-to' operator should not be used here. Do
x = &n;
You want to assign the address of n to pointer x, and not to the value pointed by pointer x.
Try referring to this code:
https://code.sololearn.com/c7mW3DQoz3m0/?ref=app
+ 11
*x=n or x=&n
both are correct.