Do you can explain this question please? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Do you can explain this question please?

What is output of this code? int x[3]={1,2,3}; int (*p) [3] = & x; cout<<(*p) [2];

4th Jan 2023, 8:40 PM
Eeee
1 Answer
0
int x[3]={1,2,3}; //In this row you declared an integer array with 3 elements. int (*p) [3] = & x; // Here you declared the variable p as container for the address off x . cout<<(*p) [2]; // Gif you as output the third element from the array x. The (*p) confused me. Wy *p dont work in steed off (*p)? *p is here the same as x. because you dereferenced it.
4th Jan 2023, 10:57 PM
Willem van Dorland
Willem van Dorland - avatar