Pointer array confusion

I am royally confused with how this code processes. I know the output is 2 since I compiled it, but I am uncertain of how the code works. Sorry, I'm new to C++ and correct me if I am wrong but

*(numbers + i) = i; is the equivalent of i += numbers;

I just don't understand the new int array in the pointer location and how that fits into the loop.

  int *numbers = new int[5];
	for (int i = 0; i <= 4; i++)
		*(numbers + i) = i;
	cout << numbers[2] << endl;   
Last edited on
It's probably better to see *(numbers + i) as equivalent to numbers[i]. Does that help?
Yes! thanks a lot.
Topic archived. No new replies allowed.