I am kind of new to pointers variables and dynamic memory allocation
so please can someone explain when the following code is outputting the following result
1 2 3 4 5 6 7 8 9 10 11
double a[10];
a[0] = 1;
for (unsigned i = 1; i < 10; i++)
a[i] = a[i - 1] * i;
p = &a[0]; // p = a;
for (unsigned i = 0; i < 10; i++)
cout << " " << p[i];
cout << endl;
p = &a[0]; // p = a;
Here you make p point to first element of the a array. Starting for this moment p is almost undistinguishable from a, and you can use p as you could use a (with some exceptions)