Pointer help

Under //m, I need to change the address in int_ptr so that it points to the third element of the array using int_ptr_ptr. How would I do this? I'm still trying to figure out pointers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  #include <iostream>

using std::cout;
using std::endl;

int main()
{
	int numbers[5] = { 99, 34, 1, 88, 100 };
	int * int_ptr = numbers;
	int ** int_ptr_ptr = &int_ptr;

	cout << "a. The address of the array is: " << &numbers << endl;
	cout << "b. The address of the array is: " << &*int_ptr << endl;
	cout << "c. The address of the array is: " << *int_ptr_ptr << endl;
	cout << "d. The address of int_ptr is: " << &int_ptr << endl;
	cout << "e. The address of int_ptr is: " << int_ptr_ptr << endl;
	cout << "f. The first element in the array is: " << *int_ptr << endl;
	cout << "g. The first element in the array is: " << **int_ptr_ptr << endl;
	//h.
	*(++int_ptr);
	cout << "i. The second element in the array is: " << *int_ptr << endl;
	cout << "j. The second element in the array is: " << **int_ptr_ptr  << endl;
	//k.
	*int_ptr = 101;
	//l.
	**int_ptr_ptr = 102;
	//m.

	return 0;
}
Last edited on
Topic archived. No new replies allowed.