I want to create an array of pointers, and each pointer should keep memory addresses of all elements from another array. But something is goind wrong.
Here is the code:
int main()
{
int a[] = { 1, 2, 3, 4, 5 };
int *b = new int[sizeof(a)];
for (int i = 0; i < sizeof(a); i++)
{
b = &a[i];
}
std::cout << &b[3] << std::endl;
std::cout << &a[3] << std::endl;
return 0;
}
When I expect is similar memory addresses, and values. Bt everything is different.