int ray[5] = { 2, 4, 6, 8, 10 }; int* p = ray; *p = ray[2]; std:: cout << *p <<" "<< *(p + 1) << std::endl;
int ray[5] = { 2, 4, 6, 8, 10 }; int* p = ray; // p points to ray[0] *p = ray[2]; // assign the value of ray[2] (6) to what p points to (ray[0]) // ray now is { 6, 4, 6, 8 10 } // p still points to ray[0]; std::cout << *p << *(p+1) << std::endl; // prints 6 (ray[0], *p) and 4 (ray[1])
int ray[5] = { 2, 4, 6, 8, 10 }; int* p = &ray[2]; std:: cout << *p <<" "<< *(p + 1) << std::endl;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)