+ 3
C++ array pointers - An output to explain
Who can explain me why this code outputs 9? int a[3][4] = {{4,8,13,9}, {1,6,9,3}, {0,2,7,10}}; cout << *(*(a+1)+2);
1 Respuesta
+ 9
A pointer to an array points to the first element of the array. Increasing the pointer by 1 will make it point to the second element etc. (*(a+1)) points to 1 (first element of {1,6,9,3} which is the second element in a), the +2 moves the pointer 2 elements further