0
The output of this code is 1. Can you brief how ?
int * test() { static int x[4]; for(int i=0;i<4;i++){ x[i] = i%2; } return x; } int main() { int * arr = test(); printf("%d", *(arr+3)); }
2 Antworten
+ 7
1
- 2
arr stores: {0 [0%2], 1 [1%2], 0 [2%2], 1 [3%2]}
*(arr+3): shifts over to element 3 indices away: 1
(explained in 100 characters)