C++ can I make a pointer to an array?

Viewed 98

Silly question but how do I make a pointer to an array in C++? My understanding is we have a pointer to the first element of an array, but what if we wanted a pointer to that pointer.

int arr[3] = { 1, 2, 3 };
auto arrp = &arr;

cout << arr << " " << arrp << endl;
cout << typeid(arr).name() << " " << typeid(arrp).name() << endl;

// 0115FC24 0115FC24
// int [3] int (*)[3]

Using the auto keyword/experimenting it seems like it can be done, but I can't type out int (*)[3] arrp = &arr;

Is there a way to type it out?

1 Answers

Pointers to arrays and function pointers have weird syntax.

int (* arrp2)[3] = &arr;
Related