#include <iostream>
using namespace std;
int main(){
int arr[4] = {1,2,3,4};
int arr2[4] = {5,6,7,8};
int **arrPtr;
arrPtr[0] = arr;
arrPtr[1] = arr2;
for (int *a : arrPtr ){
for (int i : a){
cout << i << endl;
}
}
}
I know this implementation is not the way to go but to show the intension at the end. Basically I am trying to print the content of arrays listed by another double pointer. Is there any way to make this code work?
*arrPtrdoesn't point anywhere, so assigning to it is illegal.for (int a : arr){cout << a << endl;}will give you1 2 3 4with no pointers in sight