+ 1
Could anyone explain me how the output of the following code snippet is 2?
#include <iostream> using namespace std; int main() {int a[10][20][30] = {0}; a[5][2][1] = 2; cout<<*(*(*(a+5)+2)+1); return 0; }
1 Antwort
+ 4
&ptr[0] is equal to ptr and *ptr is equal to ptr[0]&ptr[1] is equal to ptr + 1 and *(ptr + 1) is equal to ptr[1]&ptr[2] is equal to ptr + 2 and *(ptr + 2) is equal to ptr[2]&ptr[i] is equal to ptr + i and *(ptr + i) is equal to ptr[i] in c langauge
and so in cpp
*(*(*(a+5)+2)+1)===a[5][2][1]==2
its follow the 3d array a[p][q][r]
so answer is 2