3,309 views
0 votes
0 votes

How the declarations

int x; int &p=x;

and

 int x, *p; p=&x;

differ?

Please explain

1 Answer

2 votes
2 votes
&p means address of memory location p

*p means value at memory location p  ( this assumes p as pointer )

int &p;   this is not defined in C, this would give syntax error

int *p = &x;   means p is pointer and you are assigning address of memory location where value of x is stored

Related questions

0 votes
0 votes
0 answers
1
Swethapatil asked Oct 4, 2018
320 views
0 votes
0 votes
0 answers
4