+ 2
Can anyone explain the behavior of this code
#include <stdio.h> int main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p, *q; p = &a[2][2][2]; *q = ***a; printf("%d %d", *p, *q); return 0; } Why garbage value and segmentation fault is coming
3 Réponses
+ 1
Sami Khan
Code is giving this warning
https://code.sololearn.com/cWqbfjVLi6Zn/?ref=app
0
Is the code right ? am confused, a[2][2][2] here you just have 1 row 2 column and 4 values..
This should result in warning..
correct me if am wrong
0
You are reading off the end of the array. Remember that arrays are indexed beginning from 0.
You made an array of size 2 and you are reading the 3rd element.